Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

define and strlen

Posted on 2006-11-09
2
339 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
ID: 17912034
Hi william007,

The ; in the #define ...
Remove it

Cheers!
sunnycoder
0
 
LVL 16

Assisted Solution

by:PaulCaswell
PaulCaswell earned 100 total points
ID: 17912854
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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
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.

860 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