Solved

define and strlen

Posted on 2006-11-09
2
337 Views
Last Modified: 2008-03-10
#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
Comment
Question by:william007
2 Comments
 
LVL 45

Accepted Solution

by:
sunnycoder earned 400 total points
Comment Utility
Hi william007,

The ; in the #define ...
Remove it

Cheers!
sunnycoder
0
 
LVL 16

Assisted Solution

by:PaulCaswell
PaulCaswell earned 100 total points
Comment Utility
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

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now