• C

define and strlen

#include <string.h>
#include <stdio.h>
#define IIMAGE "T";
int main(){
printf("%d",strlen(IIMAGE));
}

What is the problem of this program? I expect the output to be 1 but it keep saying syntax error on the line of printf.
What is the problem and how to correct it?
LVL 9
william007Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
sunnycoderConnect With a Mentor Commented:
Hi william007,

The ; in the #define ...
Remove it

Cheers!
sunnycoder
0
 
PaulCaswellConnect With a Mentor Commented:
sunnycoder is right!

After pre-processing this line:

printf("%d",strlen(IIMAGE));

will become:

printf("%d",strlen("T";));

which is clearly not what you want.

Paul
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.