• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 349
  • Last Modified:

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?
0
william007
Asked:
william007
2 Solutions
 
sunnycoderCommented:
Hi william007,

The ; in the #define ...
Remove it

Cheers!
sunnycoder
0
 
PaulCaswellCommented:
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.

Join & Write a Comment

Featured Post

Prepare for an Exciting Career in Cybersecurity

Help prevent cyber-threats and provide solutions to safeguard our global digital economy. Earn your MS in Cybersecurity. WGU’s MSCSIA degree program curriculum features two internationally recognized certifications from the EC-Council at no additional time or cost.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now