I'm looking for a few good web sites or books to teach me Straight C. Also I'm looking for a C compiler. I know VC++ can compile C with the /Za option, and Dev-C++ can too, but they all see to be missing headers like and functions like getwd in . Thank you in advance.
Timothy Grabrian
Posts
-
Straight C, ANSI C, UNIX C, ect -
Multi-user serverI'm looking for multi-user server source code (tutorial) (C/C++, sockets, no MFC). Oh, I already know how to do multi connections the windows way (messages sent to my window when data is received), but that's not what I want. I know there are some here at codeproject but they all use MFC (yuck) and seem alot more complicated then what I've found so far. I found the original at www.planet-source-code.com (I've re-done and simplified it for this post):
SOCKET ServerSocket; SOCKADDR_IN server_address; FD_SET masterSet; HANDLE ThreadHandle; DWORD ThreadID; int RetVal = 0; DWORD WINAPI acceptingThreadProcedure(LPVOID ServerSocket) { SOCKET* Socket = (SOCKET*)ServerSocket; SOCKET ClientSocket; while(1) { ClientSocket = accept(*Socket,0,0); FD_SET(ClientSocket,&masterSet); printf("Client on %d connected\n",ClientSocket); } return TRUE; } int InitServer() { WSADATA wsaData; WSAStartup(MAKEWORD(1,0),&wsaData); ServerSocket = socket(PF_INET,SOCK_STREAM,0); server_address.sin_family = AF_INET; server_address.sin_port = 4200; server_address.sin_addr.s_addr = INADDR_ANY; bind(ServerSocket,(SOCKADDR*)&server_address,sizeof(SOCKADDR_IN)); listen(ServerSocket,5); ThreadHandle = CreateThread(NULL,0,acceptingThreadProcedure,&ServerSocket,0,&ThreadID); Sleep(100); FD_ZERO(&masterSet); FD_SET pollingSet; timeval waitTime; waitTime.tv_sec = 0; waitTime.tv_usec = 0; SOCKET clientSocket; unsigned long BufferSize; while(1) { pollingSet = masterSet; if(pollingSet.fd_count == 0) continue; RetVal = select(pollingSet.fd_count,&pollingSet,NULL,NULL,&waitTime); if(RetVal == 0) continue; for(unsigned int i = 0; i < pollingSet.fd_count; i++) { clientSocket = pollingSet.fd_array[i]; //This was his Idea recv(clientSocket,(LPSTR)&BufferSize,sizeof(BufferSize),0); BufferSize = ntohl(BufferSize); LPSTR Buffer = new char[BufferSize]; recv(clientSocket,(LPSTR)Buffer,BufferSize,0); Buffer[BufferSize] = '\0'; printf("Client %d: %s\n",clientSocket,Buffer); delete[] Buffer; } } }
I've been looking for tutorials that teach it with FD_SET and select but havn't found anything yet. Does anyone know of a good tutorial? P.S. The reason I'm looking for something more than what I've found is that the current code (above) doesn't have a wa -
Snapping windows to the desktop edgeHere is what I've coded for the task
case WM_MOVING: { LPRECT lprc = (LPRECT)lParam; RECT WD;//get width and height of window - WD = WindowDimensions GetWindowRect(hwndDlg,&WD); WD.right -= WD.left;//Width WD.bottom -= WD.top;//Height RECT VDR;//VDR = VisibleDesktopRect SystemParametersInfo(SPI_GETWORKAREA,0,&VDR,0); if(lprc->left <= VDR.left + 5 && lprc->left >= VDR.left - 5)//Left { lprc->left = VDR.left; lprc->right = lprc->left + WD.right; } if(lprc->top <= VDR.top + 5 && lprc->top >= VDR.top - 5)//Top { lprc->top = VDR.top; lprc->bottom = lprc->top + WD.bottom; } if(lprc->right >= VDR.right - 5 && lprc->right <= VDR.right + 5)//Right { lprc->right = VDR.right; lprc->left = lprc->right - WD.right; } if(lprc->bottom >= VDR.bottom - 5 && lprc->bottom <= VDR.bottom + 5)//Bottom { lprc->bottom = VDR.bottom; lprc->top = lprc->bottom - WD.bottom; } int HalfHeight = ((VDR.bottom - VDR.top) / 2) - (WD.bottom / 2); int HalfWidth = ((VDR.right - VDR.left) / 2) - (WD.right / 2 ); if ((lprc->top >= HalfHeight - 5 && lprc->top <= HalfHeight) || (lprc->top <= HalfHeight + 5 && lprc->top >= HalfHeight))//Center Up-Down { lprc->top = HalfHeight; lprc->bottom = lprc->top + WD.bottom; } if ((lprc->left >= HalfWidth - 5 && lprc->left <= HalfWidth) || (lprc->left <= HalfWidth + 5 && lprc->left >= HalfWidth))//Center Left-Right { lprc->left = HalfWidth; lprc->right = lprc->left + WD.right; } return TRUE; } break;
The only problem is after it's been snapped, when you move the mouse slowly away from the edge the window will stay put! Why does it do that? I want it to mimic DVD Decrypter Thank you. -
Secure shreddingIs there a program that will secure shred my already deleted files? (the ones you can recover with "undelete" programs?) or just like totally delete the already deleted files? P.S. I have WinXP Pro with FAT32 (120GB and 160GB) Thanks.
-
passing variablesThank you.
-
passing variablesI 2 global variables:
bool PrintBoard[5][5];
bool MemoryBoard[5][5];Then I have a function:
void DoMove(int x,int y)
{
x--;
y--;PrintBoard\[x\]\[y\] = !PrintBoard\[x\]\[y\]; if (y > 0) {//up PrintBoard\[x\]\[y - 1\] = !PrintBoard\[x\]\[y - 1\]; } if (y < 4) {//dow PrintBoard\[x\]\[y + 1\] = !PrintBoard\[x\]\[y + 1\]; } if (x > 0) {//left PrintBoard\[x - 1\]\[y\] = !PrintBoard\[x - 1\]\[y\]; } if (x < 4) {//right PrintBoard\[x + 1\]\[y\] = !PrintBoard\[x + 1\]\[y\]; } return;
}
As you can see, the DoMove function only changes PrintBoard. I would like it to be able to change either variable with out much more code (I don't see the point of re-using code here). I was thinking I could do something like adding another argument to the function that I could pass the global to it, but I couldn't figure out how. Any Ideas? Thanks
-
Word Document to PDF -
variablesThanks all, I got it.
-
variablesOh, yeah, I wasn't talking simplifying like that, I meant something like BYTE GridPos = &grid[x][y];//might not even need this GridPos &= GridPos; (I know thats wrong, but thats what I'm thinking it should look like, just diffrent opperators)
-
variablesHow can I simplify this: grid[x][y] == 0 ? grid[x][y] = 1 : grid[x][y] = 0; I was thinking that I could make a pointer (or address) to that part of the array, then like shift the bits or something (each part of the array is a BYTE), but I couln't figure out how to do it. Any ideas? thanks
-
Log outI'm using FireFox 1.0 and I sign then go to the forums, post and as soon as its posted I'm signed out. As long as I don't post I stay signed in.
-
Text Editor Source CodeI would really suggest you read this entire tutorial: http://winprog.org/tutorial/ But what you really need are these two pages: http://winprog.org/tutorial/app\_two.html and http://winprog.org/tutorial/app\_three.html wWw.KruncherInc.cOm
-
Copy ScreenI'm trying to capture the whole screen, paint it in my fullscreen window, then add effects to it (transitions and such). I have a fealing I have to use CreateCompatibleDC but I can't figure out where. Here is a simplified version of what my code looks like: INT ScreenWidth = GetSystemMetrics(SM_CXSCREEN); INT ScreenHeight = GetSystemMetrics(SM_CYSCREEN); HDC DesktopDC = GetDC(0);//I do this before my window is displayed HDC MyDC = GetDC(hWnd);//hWnd Is my window BitBlt(MyDC,0,0,ScreenWidth,ScreenHeight,DesktopDC,0,0,SRCCOPY);//Trying to cover my window Any one care to help? (WIN32 API only please) Also could you show me how to double buffer for flicker free drawing? P.S. GDI is tough wWw.KruncherInc.cOm
-
WM_CTLCOLORBTNWhy does WM_CTLCOLORBTN not work, it doesn't respond to things like SetBkColor and such like WM_CTLCOLORSTATIC does. Whats up with that? wWw.KruncherInc.cOm
-
web serverI don't know of any HTTPS server source code, but this site has HTTP server source code, mabye you could modify it to work for HTTPS. http://www.vijaymukhi.com/vmis/vmchap4.htm Mabye www.sourceforge.net might something HTTPS also wWw.KruncherInc.cOm
-
Owner Drawn ButtonOh, I'm sorry, I forgot to mention that this program is all WIN32 not MFC. wWw.KruncherInc.cOm
-
Owner Drawn ButtonI would like to paint a focus rect around the inside of my buttons, I can not figure out how to make a brush that is the text color every other pixel (like the standard windows buttons focus rect) wWw.KruncherInc.cOm
-
IdioticDo You have a better way? That is the only way I ever got my DosBox apps to go full screen wWw.KruncherInc.cOm
-
Unicode compilingYeah I was going to do that, but I couldn't find where to do it at. wWw.KruncherInc.cOm
-
Unicode compilingI have a app that needs to read and write stuff to the reg, I have my custom Reg functions in a seperate CPP file "RegHelpers.cpp" along with a header file "RegHelpers.h". If I uncomment these 2 lines it gives a "unresolved external symbol" error for the functions in "RegHelpers.h" //#define _UNICODE //#define UNICODE #include #include #include "resource.h" #include "RegHelpers.h" I can not figure out what the problem is!!! To make my program fully Unicode don't I need to change some Preprocessor settings? Also, I used to use strings like this all the time: LPSTR String = new char[256]; then I learnt about unicode, so I started doing them this way: PTCHAR String = new TCHAR[256]; Do I need to do "new TCHAR[256 * sizeof(TCHAR)];"? Also should I change them from PTCHAR to LPTSTR? Do I really need to use the new operator on my strings? Haha I'm really starting to hate data types. wWw.KruncherInc.cOm