简体   繁体   中英

I'm trying this simple code and I get this error

#include<iostream>
#include<curses.h>
int main()
{
std::cout<<" alert \a";
getstr();
return 0;
}

I get this error:

Expected primary expression before ')' token getstr();

getstr requires a char pointer as a parameter. This is where it will store the string from user input. As Dampen59 pointed out, this is the function signature.

int getstr(char *str);

The prototype of the function is:

int getstr(char *str);

as you read in the ref .

You are not passing any argument, thus you get an error.

You can't call getstr() without an argument, though the exception does a bad job of telling you that. I had similar problems starting out with c++. Try this:

int getstr(char *str);

Looks like a few people beat me to this answer though.

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