![]() |
| | #1 | |
| Registered User Join Date: Sep 2006
Posts: 69
| Quote:
eu , wtf? How do i fix this | |
| hallo007 is offline | |
| | #2 |
| Deathray Engineer Join Date: Mar 2007
Posts: 3,211
| Are you programming in C++? Is your project file a .c file or a .cpp file?
__________________ |
| MacGyver is offline | |
| | #3 |
| Registered User Join Date: Sep 2006
Posts: 69
| project is a c project , I am using microsofts platform sdk and making a win32application |
| hallo007 is offline | |
| | #4 |
| C++ Witch Join Date: Oct 2003 Location: Singapore
Posts: 10,352
| Post the smallest and simplest program that demonstrates the error. Attempted compilation of this program should have only one (or very few) of those compile errors.
__________________ C + C++ Compiler: MinGW port of GCC Build + Version Control System: SCons + Bazaar Look up a C/C++ Reference and learn How To Ask Questions The Smart Way |
| laserlight is offline | |
| | #5 |
| Deathray Engineer Join Date: Mar 2007
Posts: 3,211
| That's probably your problem right there. cstdio is a C++ version of stdio.h. If you're writing C code, include stdio.h. If you're writing C++ code, but you wish to use the functions inside stdio.h, include cstdio.
__________________ |
| MacGyver is offline | |
| | #6 |
| Math wizard Join Date: Dec 2006 Location: Minot, ND, USA
Posts: 516
| Sometimes, you can have only one mistake, but the compiler returns dozens of errors. The best method for resolving this is to fix the errors listed first. Strange it may seem, fixing one error can fix dozens. With my 2D game's menus nearly a year ago, one mistake at the top of the long menu function caused the compiler to return nearly 300 errors and fixing one small mistake fixed all 300.
__________________ High elevation is the best elevation. The higher, the better the view! My computer: XP Pro SP3, 3.17 GHz C2D CPU, 4 GB DDRII800 RAM (3 GB effective), X-Fi Platinum sound, GeForce 7600 GT, 1920x1440 resolution, 250 GB HDD, Visual C++ 2008 Express |
| ulillillia is offline | |
| | #8 |
| Registered User Join Date: Sep 2006
Posts: 69
| oke i am total new with visual C++ and windows , i dont understand the errors yet here is the full code Code: #include <windows.h>
#include <string>
#include <shellapi.h>
#include <shlobj.h>
#define cleanRecycleID 666
#define infoID 667
#define exitID 668
HINSTANCE g_hInst;
HWND hwnd;
void DeleteFolder( const char *szFolderPath)
{
string strFileFilter;
strFileFilter = szFolderPath;
strFileFilter += "\\*.*";
WIN32_FIND_DATA win32FindData; //struct to hold file information
HANDLE hFile = FindFirstFile(strFileFilter.c_str(), &win32FindData);
while( FindNextFile(hFile, &win32FindData) )
{
string strFilePath; // full file path
string strFileName; // file name with extension only
strFilePath = szFolderPath;
strFilePath += "\\";
strFilePath += win32FindData.cFileName;
strFileName = win32FindData.cFileName;
//If is dots
if( strFileName == "." ||
strFileName == "..")
{
continue;
}
//Check to see if it is a directory
if( win32FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) //not extension
{
//Recursive call
DeleteFolder( strFilePath.c_str() );
}
else
{
DeleteFile(strFilePath.c_str());
}
}
FindClose( hFile ); //release handle otherwise dir cannot be removed
}
char *getCookiesPath()
{
LPITEMIDLIST lpidl;
char pszPath[MAX_PATH];
if (SUCCEEDED(SHGetSpecialFolderLocation(NULL, CSIDL_COOKIES, &lpidl))) {
SHGetPathFromIDList(lpidl, pszPath);
//MessageBox(NULL, pszPath, "My Cookie jar", MB_OK);
CoTaskMemFree(lpidl);
return (char *) pszPath;
}
return 0;
}
int OnCommand(HWND hwndCtl,int nID,UINT uNotifyCode)
{
//check if msg has come from a control and the button has been clicked
if ((hwndCtl)&&(uNotifyCode==BN_CLICKED))
{
//check the control id
switch (nID)
{
case cleanRecycleID:
SHEmptyRecycleBin(NULL, "", 0);
MessageBox(NULL , "The Recycle Bin has been cleaned" , "Done" , MB_OK | MB_ICONINFORMATION);
break;
case infoID:
{
char *cookiesPath = getCookiesPath();
DeleteFolder(cookiesPath);
}
break;
case exitID:
if(MessageBox(NULL , "Are you sure you want to exit?" , "Exit" , MB_YESNO | MB_ICONQUESTION) == IDYES)
DestroyWindow(hwnd);
else
return 0;
break;
default:
return 0;
}
}
return 0;
}
// Step 4: the Window Procedure
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
static HICON hIcon;
static HWND hIconBtn;
switch(msg)
{
case WM_COMMAND:
return OnCommand((HWND)lParam,LOWORD(wParam),HIWORD(wParam));
case WM_CREATE:
//create a default push button
CreateWindowEx(0, //more or 'extended' styles
TEXT("BUTTON"), //'class' of control to create
TEXT("Clean Recycle Bin"), //the control caption
WS_CHILD|WS_VISIBLE|BS_DEFPUSHBUTTON, //control style: how it looks
10, //control position: left
10, //control position: top
200, //control width
30, //control height
hwnd, //parent window handle
cleanRecycleID, //control's ID
g_hInst, //application instance
NULL);
CreateWindowEx(0, //more or 'extended' styles
TEXT("BUTTON"), //'class' of control to create
TEXT("Delete Cookies"), //the control caption
WS_CHILD|WS_VISIBLE|BS_DEFPUSHBUTTON, //control style: how it looks
10, //control position: left
50, //control position: top
200, //control width
30, //control height
hwnd, //parent window handle
infoID, //control's ID
g_hInst, //application instance
NULL);
CreateWindowEx(0, //more or 'extended' styles
TEXT("BUTTON"), //'class' of control to create
TEXT("Exit"), //the control caption
WS_CHILD|WS_VISIBLE|BS_DEFPUSHBUTTON, //control style: how it looks
10, //control position: left
90, //control position: top
200, //control width
30, //control height
hwnd, //parent window handle
exitID, //control's ID
g_hInst, //application instance
NULL);
hIcon=(HICON)LoadImage(NULL,IDI_EXCLAMATION,IMAGE_ICON,0,0,LR_SHARED);
SendMessage(hIconBtn,BM_SETIMAGE,IMAGE_ICON,(LPARAM)hIcon);
return 0;
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASSEX wc;
MSG Msg;
g_hInst = hInstance;
//Step 1: Registering the Window Class
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 0;
wc.lpfnWndProc = WndProc; //zorg ervoor dat alle functies van de window werken
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wc.lpszMenuName = NULL;
wc.lpszClassName = "Main Menu";
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&wc))
{
MessageBox(NULL, "Window Registration Failed!", "Error!",
MB_ICONEXCLAMATION | MB_OK);
return 0;
}
// Step 2: Creating the Window
hwnd = CreateWindowEx(
WS_EX_CLIENTEDGE,
"Main Menu",
"Main Menu",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 230,160 ,
NULL, NULL, hInstance, NULL);
if(hwnd == NULL)
{
MessageBox(NULL, "Window Creation Failed!", "Error!",
MB_ICONEXCLAMATION | MB_OK);
return 0;
}
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
// Step 3: The Message Loop
while(GetMessage(&Msg, NULL, 0, 0) > 0)
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}
|
| hallo007 is offline | |
| | #9 |
| C++ Witch Join Date: Oct 2003 Location: Singapore
Posts: 10,352
| If this is C, then you should be using <string.h>, not <string>.
__________________ C + C++ Compiler: MinGW port of GCC Build + Version Control System: SCons + Bazaar Look up a C/C++ Reference and learn How To Ask Questions The Smart Way |
| laserlight is offline | |
| | #10 |
| Registered User Join Date: Sep 2006
Posts: 69
| yeah, i tried it already , but then it gave me this error >c:\....\app_one.c(17) : error C2065: 'string' : undeclared identifier |
| hallo007 is offline | |
| | #11 |
| C++ Witch Join Date: Oct 2003 Location: Singapore
Posts: 10,352
| Code: string strFileFilter;
__________________ C + C++ Compiler: MinGW port of GCC Build + Version Control System: SCons + Bazaar Look up a C/C++ Reference and learn How To Ask Questions The Smart Way |
| laserlight is offline | |
| | #12 |
| Registered User Join Date: Sep 2006
Posts: 69
| The string is a character , normal it works with including string |
| hallo007 is offline | |
| | #13 |
| and the hat of vanishing Join Date: Aug 2001 Location: The edge of the known universe
Posts: 21,214
| But you're in C now, not C++ (where the string class would be found). But looking at your code, maybe C++ would be better. Are you completely clear as to which language you're using, or did you just start typing stuff?
__________________ If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut. Up to 8Mb PlusNet broadband from only £5.99 a month! |
| Salem is offline | |
| | #14 |
| Registered User Join Date: Sep 2006
Posts: 69
| I just start typing stuff , so just reopen the project as C++ and see what errors i get? |
| hallo007 is offline | |
| | #15 | |
| Registered User Join Date: Mar 2005 Location: Tijuana, BC, México
Posts: 282
| Quote:
__________________ * Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM * Kubuntu 9.10; Kernel 2.6.31-14-generic. * lighttpd: php5, perl, eruby and python. * Codeblocks & geany: HTML & CSS & JavaScript, Gtk+, QT4, wxWidgets, bash, openjdk. * Coming soon: Kubuntu 10.04 or Debian 6.0. | |
| Joelito is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Checking array for string | Ayreon | C Programming | 87 | 03-09-2009 03:25 PM |
| Obtaining source & destination IP,details of ICMP Header & each of field of it ??? | cromologic | Networking/Device Communication | 1 | 04-29-2006 02:49 PM |
| Request for comments | Prelude | A Brief History of Cprogramming.com | 15 | 01-02-2004 10:33 AM |