J
J.Broeden
Hi, I've written a some code to assist in my understanding of strings
using some of Cs built in character handling functions but I am not
sure why I'm getting the following error.
I hope someone can explain the errors of my ways.
/* Looking for special chars in testlist */
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main ()
{
int i;
char test2[10] = "ab c1% 4!.";
for (i=0; i <= 10; i++)
{
if ((ispunct((int) test2)) && (test2 != "."))
{
printf("i= %d is punct\n",i);
}
}
return 0;
}
When I use gcc -Wall -Werror to compile I get the following warning:
searchstring_ispunct.c: In function `main':
searchstring_ispunct.c:14: warning: comparison between pointer and
integer
I don't understand why the compiler is seeing the (test2 !=".") as
an integer.
Could someone possibly explain why this is the case please ?
Thank you
Jay
using some of Cs built in character handling functions but I am not
sure why I'm getting the following error.
I hope someone can explain the errors of my ways.
/* Looking for special chars in testlist */
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main ()
{
int i;
char test2[10] = "ab c1% 4!.";
for (i=0; i <= 10; i++)
{
if ((ispunct((int) test2)) && (test2 != "."))
{
printf("i= %d is punct\n",i);
}
}
return 0;
}
When I use gcc -Wall -Werror to compile I get the following warning:
searchstring_ispunct.c: In function `main':
searchstring_ispunct.c:14: warning: comparison between pointer and
integer
I don't understand why the compiler is seeing the (test2 !=".") as
an integer.
Could someone possibly explain why this is the case please ?
Thank you
Jay