'identifier' : undeclared identifier
A variable’s type must be specified in a declaration before it can be used. The parameters that a function uses must be specified in a declaration, or prototype, before the function can be used.
Possible causes
#include <stdio.h> main() { printf("\n %s %s // error: 's' : undeclared identifier %s", "this", "is", "it"); }
Take special care when you split a constant string over several lines. One method is to change the format string. Strings separated only by whitespace (spaces, tabs, newlines) are concatenated:
#include <stdio.h> main() { printf("\n %s" " %s" " %s", "this", "is", "it"); }
A less-preferable method uses a backslash at the end of a line. The spaces at the beginning of each continued line become part of the string:
printf("\n %s\ %s\ %s", "this", "is", "it");
std
namespace with the using directive. The following example fails to compile because the using directive is commented out and cout is defined in the std
namespace:
#include <iostream> // using namespace std; void main() { cout << "Hello" << endl; }