0

I have the task of finding out if one of the many strings in my array contains an @ character.

Example -

I am @HOME or @SCHOOL

If the string does contain the @ i want to print out the string.

arr is declared as follows

char* arr[10][100];

I thought of using this

   if(strstr(arr[j], "@") != NULL);
   {
      printf("hey\n");
   }

but it prints out every single string whether or not they have the @.

0

1 Answer 1

1

Remove semicolon after the if condition. Like

if(strstr(outputArr[j], "@") != NULL)

Because

 if(strstr(outputArr[j], "@") != NULL);

is equivalent to

if(strstr(outputArr[j], "@") != NULL)
{

}

C99-6.8.3 paragraph 3:

A null statement (consisting of just a semicolon) performs no operations.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.