strlen + terminating null character

L

lasek

Hi all, a simple question, please look this code below:

char acName[]="Claudio" // My name
unsigned int uiLen;

uiLen=strlen(acName);

printf("Lenght of acName [%d]",uiLen);

printf("Display acName[iLenLenght of acName [%d]",uiLen);

printf("Lenght of acName [%d]",uiLen);
 
C

CBFalconer

lasek said:
Hi all, a simple question, please look this code below:

char acName[]="Claudio" // My name
unsigned int uiLen;

uiLen=strlen(acName);
printf("Lenght of acName [%d]",uiLen);
printf("Display acName[iLenLenght of acName [%d]",uiLen);
printf("Lenght of acName [%d]",uiLen);

So, what is the question? Length is misspelled. The code is
incomplete and won't compile, but seems reasonable, apart from the
use of // comments (which are bad in usenet because of line wrap,
and invalid if you don't have a C99 compiler, which most don't).
You are also allowed to use blanks around such tokens as = or after
a comma. They don't cost much, and there is no shortage nor
environmental price.
 
K

Keith Thompson

lasek said:
Hi all, a simple question, please look this code below:

char acName[]="Claudio" // My name
unsigned int uiLen;

uiLen=strlen(acName);

printf("Lenght of acName [%d]",uiLen);

printf("Display acName[iLenLenght of acName [%d]",uiLen);

printf("Lenght of acName [%d]",uiLen);

In addition to the comments provided by others, you should use "%u" to
print an unsigned int, not "%d".

It looks like you meant to say more than you did. Say it, and we'll
respond.
 
C

Christopher Benson-Manica

Keith Thompson said:
It looks like you meant to say more than you did. Say it, and we'll
respond.

It turns out he did, in his next post, but none of us noticed it
before responding to this one. Oh well.
 
K

Keith Thompson

Christopher Benson-Manica said:
It turns out he did, in his next post, but none of us noticed it
before responding to this one. Oh well.

Right, because he started a new thread.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top