In my program i declared a function prototype like :
void callToPrint(LPTSTR , LPVOID , DWORD , string )
But i get the following error due to this statement : error C2061: syntax error : identifier 'string'
There are other errors also in the code which tell that the function does not take 4 arguments.
(error C2660: 'callToPrint' : function does not take 4 arguments)
Why do i get this error ? And how can i fix them ?
My second question is :
- I have declared a variable
nameofPrinterof typeLPTSTRbut when i write the statementgetline( cin , nameOfPrinter ), the error displayed is no instance of overloaded functiongetlinematches the argument list. Then how can i receive thenameOfPrinterfrom the user ?
Your file needs to contain the following line:
The header file
stringcontains the definition for thestringclass. Because that class is within thestdnamespace the function prototype needs to be:Since you’re using
LPTSTRin the prototype you must be using Visual C++. If your project is set to use Unicode charset instead of multi-byte char set you need to adapt your types accordingly.For Unicode charset:
Or, you could declare the type of your strings as:
Unfortunately, such a templated class does not exist for switching between
cinandwcin. So you’ll have to resort to the preprocessor.