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);
|
|
0
|
|
|
|
Reply
|
claudio.rossetti (23)
|
3/25/2005 12:07:17 PM |
|
lasek <claudio.rossetti@acrm.it> spoke thus:
> 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);
What's the question? All three printf's print the same number, which
is 7.
--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
|
|
0
|
|
|
|
Reply
|
ataru (1609)
|
3/25/2005 1:37:16 PM
|
|
lasek wrote:
>
> 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.
--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
|
|
0
|
|
|
|
Reply
|
cbfalconer (19183)
|
3/25/2005 6:32:59 PM
|
|
"lasek" <claudio.rossetti@acrm.it> writes:
> 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.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
|
|
0
|
|
|
|
Reply
|
kst-u (21467)
|
3/25/2005 8:38:50 PM
|
|
Keith Thompson <kst-u@mib.org> spoke thus:
> 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.
--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
|
|
0
|
|
|
|
Reply
|
ataru (1609)
|
3/25/2005 8:53:13 PM
|
|
Christopher Benson-Manica <ataru@nospam.cyberspace.org> writes:
> Keith Thompson <kst-u@mib.org> spoke thus:
>> 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.
Right, because he started a new thread.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
|
|
0
|
|
|
|
Reply
|
kst-u (21467)
|
3/26/2005 12:07:46 AM
|
|
|
5 Replies
30 Views
(page loaded in 0.059 seconds)
|