Hello

I am trying to get this function to work...

int error(const char* s)
{
	int f=1;
	
        while (*s!='/0')
       {
              if(*s=='/')
	     {
		  f=0;
		  return(f);
	     }
	      s++;
       }
return f;
}

I want to find out if in the string tat i am passing there is a character "/"....But i am getting a runtime error....wat am i doing wrong? Kindly help..
Thanks in advance...

Edited 6 Years Ago by wtvrinc: bad indentation

Well for 10 lines of code, the indentation sucks.
Is the rest of your code an unreadable mess?

Do you get any warnings when you compile?

$ gcc -W -Wall -O2 -c foo.c
foo.c:5:14: warning: multi-character character constant
foo.c: In function ‘error’:
foo.c:5: warning: comparison is always true due to limited range of data type

Hint: consider the difference between /0 and \0

No, i did not get any warnings....It just encounters error while executing...However if i use "a" or some letter instead of "/"...i am not getting error...

This question has already been answered. Start a new discussion instead.