Siddharth Narayanan
Siddharth Narayanan

Reputation: 11

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();

Upvotes: 1

Views: 59

Answers (3)

Cubemaster
Cubemaster

Reputation: 517

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.

Upvotes: 0

gsamaras
gsamaras

Reputation: 73366

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.

Upvotes: 0

Jacob Boertjes
Jacob Boertjes

Reputation: 971

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);

Upvotes: 2

Related Questions