actually I had several spaces, either I didn''t type them in to the first post or they got removed by the board. initializing the strings with {" "} several spaces got rid of several invalid charecters but not the first and last ones.
char szPrime01 [12] = {"\0"}; compiled, ran, still get invalid charecters
char szPrime01 [12] = {"0"}; compiled, ran, still get invalid charecters
char szPrime01 [12] = {0}; compiled, ran, still get invalid charecters
char szPrime01 [12] = 0; invalid initializer
heres the entire program
#include <windows.h>#include <string>#include <stdio.h>HWND hwnd ;int iLength;char szPrime01 [12] = {"\0"};char szPrime02 [12] = {"\0"};char szPrime03 [12] = {"\0"};char szPrime04 [12] = {"\0"};char szPrime05 [12] = {"\0"};unsigned long int realnum = 3, divisor = 2;unsigned short int count = 0; //, fuse = 0;char quit;bool OnOff = true;// char *psPrime = TEXT ("Found Prime number:"); a pointer to a text string// text out worked with a constant string but not the pointerLRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;void PrimeGenerator ();int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow){ static TCHAR szAppName[] = TEXT ("PrimeFinderWin01") ; MSG msg ; WNDCLASS wndclass ; wndclass.style = CS_HREDRAW | CS_VREDRAW ; wndclass.lpfnWndProc = WndProc ; wndclass.cbClsExtra = 0 ; wndclass.cbWndExtra = 0 ; wndclass.hInstance = hInstance ; wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ; wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ; wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ; wndclass.lpszMenuName = NULL ; wndclass.lpszClassName = szAppName ; if (!RegisterClass (&wndclass)) { MessageBox (NULL, TEXT ("This program requires Windows NT!"), szAppName, MB_ICONERROR) ; return 0 ; } hwnd = CreateWindow (szAppName, // window class name TEXT ("Prime Finder windows 01"), // window caption WS_OVERLAPPEDWINDOW, // window style CW_USEDEFAULT, // initial x position CW_USEDEFAULT, // initial y position CW_USEDEFAULT, // initial x size CW_USEDEFAULT, // initial y size NULL, // parent window handle NULL, // window menu handle hInstance, // program instance handle NULL) ; // creation parameters ShowWindow (hwnd, iCmdShow) ; UpdateWindow (hwnd) ; while ( true) { if (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)) { if (msg.message == WM_QUIT) break; TranslateMessage (&msg) ; DispatchMessage (&msg) ; } if (OnOff == true) PrimeGenerator (); } return msg.wParam ;}LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){ static int cxChar, cxCaps, cyChar ; HDC hdc ; PAINTSTRUCT ps ; RECT rect ; TCHAR szBuffer [10] ; TEXTMETRIC tm ; switch (message) { case WM_CREATE: // PlaySound (TEXT ("hellowin.wav"), NULL, SND_FILENAME | SND_ASYNC) ; // a relic of the original program hdc = GetDC (hwnd) ; GetTextMetrics (hdc, &tm) ; cxChar = tm.tmAveCharWidth ; cxCaps = (tm.tmPitchAndFamily & 1 ? 3 : 2) * cxChar / 2 ; cyChar = tm.tmHeight + tm.tmExternalLeading ; ReleaseDC (hwnd, hdc) ; return 0 ; case WM_PAINT: hdc = BeginPaint (hwnd, &ps) ; GetClientRect (hwnd, &rect) ; TextOut (hdc, 0, cyChar * 0, TEXT ("Found Prime number:"), 19) ; TextOut (hdc, 0, cyChar * 1, TEXT ("Found Prime number:"), 19) ; TextOut (hdc, 0, cyChar * 2, TEXT ("Found Prime number:"), 19) ; TextOut (hdc, 0, cyChar * 3, TEXT ("Found Prime number:"), 19) ; TextOut (hdc, 0, cyChar * 4, TEXT ("Found Prime number:"), 19) ; TextOut (hdc, cxChar * 20, cyChar * 0, szPrime01, 12) ; TextOut (hdc, cxChar * 20, cyChar * 1, szPrime02, 12) ; TextOut (hdc, cxChar * 20, cyChar * 2, szPrime03, 12) ; TextOut (hdc, cxChar * 20, cyChar * 3, szPrime04, 12) ; TextOut (hdc, cxChar * 20, cyChar * 4, szPrime05, 12) ; //DrawText (hdc, TEXT ("Will I even be using this text function?!"), -1, &rect, // DT_SINGLELINE | DT_LEFT | DT_TOP) ; EndPaint (hwnd, &ps) ; Sleep (100); return 0 ; case WM_DESTROY: PostQuitMessage (0) ; return 0 ; } return DefWindowProc (hwnd, message, wParam, lParam) ;}void PrimeGenerator (){if (divisor >= realnum) { // std::cout << "Prime number: " << realnum << "\n"; doesn''t work in win32 /* cannot copy strings or arrays!!! szPrime01 = szPrime02; szPrime02 = szPrime03; szPrime03 = szPrime04; szPrime04 = szPrime05; */ strcpy ( szPrime01, szPrime02); strcpy ( szPrime02, szPrime03); strcpy ( szPrime03, szPrime04); strcpy ( szPrime04, szPrime05); sprintf ( szPrime05, TEXT (" %u "), realnum); // szPrime05 = realnum; can''t convert from unsigned int to char string InvalidateRect (hwnd, NULL, TRUE); realnum += 2; divisor = 2; count++; if (count >= 15) { OnOff = false; // std::cout << "Do you want to quit?(y to quit)\n"; doesn''t work in win32 // std::cin >> quit; same here /* all work and no play yada yada yada if ( quit == ''y'' ) break; else count = 0; */ } } if ((realnum % divisor) != 0) { divisor++; } else { realnum += 2; divisor = 2; /* for some reasion this if (fuse = 60000) counter quit the program { before it should have!? break; } */ } }
Bloodshed Dev-C++ 4.9.8.0
DX 9.0a DX SDK 6.1
win98
#define WIN32_LEAN_AND_MEAN
the Particle Projection Cannon fires a shimmering blue bolt, much like a cross between lightning and a sine wave that ripples along its path.
Bloodshed Dev-C++ 4.9.8.0 Mingw DX 9.0a DX SDK 6.1win2k#define WIN32_LEAN_AND_MEANthe Particle Projection Cannon fires a shimmering blue bolt, much like a cross between lightning and a sine wave that ripples along its path.mechwarrior 2 mercenaries, 4 particle projection cannons, thug chassis