for a program in which I try to create a file and later write into it, I have written the following:
int main(){ ... .... (some code) .... char DataBuffer[] = "This is the test file"; ... ... } I get the error "DataBuffer: undeclared identifier" . I am using Microsoft Visual C++ Express. And in an old asked question here in stackoverflow.com, I have read that Visual C++ uses an old C89 standard and that it does not support C99 standard. For that reason, I must declare the variables at the beginning(which I did for the rest of the parameters of CreateFile() and WriteFile). I mean, when you consider the following:
DWORD dwCreationDisposition = CREATE_NEW; Then I split it up and changed it to:
DWORD dwCreationDisposition; ... dwCreationDisposition = CREATE_NEW but I do not know how I should do it with an array. So, for example when I write:
char DataBuffer[]; .... DataBuffer[] = = "This is the test file"; Then I also get the same error message. What can I do ? Is there any possibility to change the compiler options ? Or a chance to rewrite it such that the integrated compiler accepts it as the other splitted variables/parameters ?
best regards,
char *DataBuffer; /* ... */ DataBuffer = "string";{}in order to declare a new variable there. Note that what @Mint97 suggests is different, because it declares a pointer to non-constant data which you still may not modify, while the original code declared a mutable array of chars.