简体   繁体   中英

Why does function not recognize pointer? [on hold]

Wrote a code to take in a string of words and remove the spaces from the end and start. Started the code with

void trim(char *source, char *new)

Visual Studio says missing ')' before 'new'. There are like 5 more errors, all stemming from this "new". What could be causing this?

While this function signature is allowed in C, this will not work in C++ because new is a keyword in that language and can't be used as an identifier (such as the name of a parameter).

To solve this issue, make sure that you're compiling your C program as such, and not as a C++ program. To get this code to run in C++, just rename the parameter.

See here :

the identifiers that are keywords cannot be used for other purposes;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM