#include<stdio.h>
#include<string.h>
void try(char s[])
{
if(strlen(s)>5)
{
puts("Error\n");
}
}
int main()
{
char string[10];
int T;
scanf("%d",&T);
while(T--)
{
scanf("%s",&string);
try(string);
}
return 0;
}
Still can't find the error... try is a simple function and as always i am creating a func and calling it. compiler is giving error - (expected unqualified-id before 'try')
I suspect you are trying to compile your code as C++ rather than C. In C++, try is a reserved word (it is used in exception handling).
$ gcc test.c
$ g++ test.c
test.c:3:6: error: expected unqualified-id before 'try'
You can use -x to set the language explicitly (with either gcc or g++):
$ gcc -x c test.c
$ gcc -x c++ test.c
test.c:3:6: error: expected unqualified-id before 'try'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With