print 19 on screen | | |
#include <stdio.h>
int main()
{
char p='19';
-----------------
return 0;
}
can anyone tell me what is the missing statement by writing which 19
will be printed on screen ??? | | | | re: print 19 on screen
asit wrote: Quote:
#include <stdio.h>
>
int main()
{
char p='19';
What do you expect this to do? | | | | re: print 19 on screen
On Jan 14, 6:19 pm, Mark Bluemel <mark_blue...@pobox.comwrote: Quote:
asit wrote: Quote:
#include <stdio.h>
> Quote:
int main()
{
char p='19';
//write a statement to print 19 on screen
return 0;
} | | | | re: print 19 on screen
In article <3322f292-0068-4841-a52d-d765cc705acd@i3g2000hsf.googlegroups.com>,
asit <lipun4u@gmail.comwrote: Quote:
>#include <stdio.h>
>
>int main()
>{
char p='19';
-----------------
return 0;
>}
>
>
>can anyone tell me what is the missing statement by writing which 19
>will be printed on screen ???
You could try
printf("19\n");
Perhaps you meant the preceding line to be
char *p="19";
in which case
printf("%s\n", p);
would work.
-- Richard
--
:wq | | | | re: print 19 on screen
On Jan 14, 6:16 pm, asit <lipu...@gmail.comwrote: Quote:
#include <stdio.h>
>
int main()
{
char p='19';
-----------------
return 0;
>
}
>
can anyone tell me what is the missing statement by writing which 19
will be printed on screen ???
plz note that here p is a character. i want to access whole '19' from p | | | | re: print 19 on screen
In article <a3daba28-4b20-499d-8794-105c1d2cf00e@t1g2000pra.googlegroups.com>,
asit <lipun4u@gmail.comwrote: Quote:
>plz note that here p is a character. i want to access whole '19' from p
But '19' is not a character. Character constants containing more than
one character do something implementation-defined. Most likely it's
just the same as '9', in which case you're not going to be able to get
'19' out of it.
-- Richard
--
:wq | | | | re: print 19 on screen
asit wrote: Quote:
On Jan 14, 6:19 pm, Mark Bluemel <mark_blue...@pobox.comwrote: Quote:
>asit wrote: Quote:
>>#include <stdio.h>
>>int main()
>>{
>> char p='19';
//write a statement to print 19 on screen
return 0;
}
>
You snipped the vital part of my posting.
What do you expect "char p='19';" to achieve? | | | | re: print 19 on screen
Richard Tobin wrote: Quote:
In article <a3daba28-4b20-499d-8794-105c1d2cf00e@t1g2000pra.googlegroups.com>,
asit <lipun4u@gmail.comwrote:
> Quote:
>plz note that here p is a character. i want to access whole '19' from p
>
But '19' is not a character. Character constants containing more than
one character do something implementation-defined. Most likely it's
just the same as '9', in which case you're not going to be able to get
'19' out of it.
Alternatively, if you meant the numeric value 19, you could simply write
#include <stdio.h>
int main()
{
char p=19;
printf("%d\n",(int)p);
return 0;
} | | | | re: print 19 on screen
On Jan 14, 6:55 pm, Mark Bluemel <mark_blue...@pobox.comwrote: Quote:
asit wrote: Quote:
On Jan 14, 6:19 pm, Mark Bluemel <mark_blue...@pobox.comwrote: Quote:
asit wrote:
>#include <stdio.h>
>int main()
>{
> char p='19';
//write a statement to print 19 on screen
return 0;
}
>
You snipped the vital part of my posting.
>
What do you expect "char p='19';" to achieve?
i want to access 19 from p in GCC compiler ??? | | | | re: print 19 on screen
asit wrote: Quote:
On Jan 14, 6:55 pm, Mark Bluemel <mark_blue...@pobox.comwrote: Quote:
>asit wrote: Quote:
>>On Jan 14, 6:19 pm, Mark Bluemel <mark_blue...@pobox.comwrote:
>>>asit wrote:
>>>>#include <stdio.h>
>>>>int main()
>>>>{
>>>> char p='19';
>> //write a statement to print 19 on screen
>> return 0;
>> }
>You snipped the vital part of my posting.
>>
>What do you expect "char p='19';" to achieve?
>
>
i want to access 19 from p in GCC compiler ???
What you have coded states that p is a char, not a pointer to char,
not a string of characters, but a single char data item.
You then specify an initial value for it which is not a single
character. This is not wise... | | | | re: print 19 on screen
In article <fmfq1e$848$1@aioe.org>,
Mark Bluemel <mark_bluemel@pobox.comwrote: Quote:
>asit wrote: Quote:
>On Jan 14, 6:55 pm, Mark Bluemel <mark_blue...@pobox.comwrote: Quote:
>>asit wrote:
>>>On Jan 14, 6:19 pm, Mark Bluemel <mark_blue...@pobox.comwrote:
>>>>asit wrote:
>>>>>#include <stdio.h>
>>>>>int main()
>>>>>{
>>>>> char p='19';
>>> //write a statement to print 19 on screen
>>> return 0;
>>> }
>>You snipped the vital part of my posting.
>>>
>>What do you expect "char p='19';" to achieve?
>>
>>
>i want to access 19 from p in GCC compiler ???
>
>What you have coded states that p is a char, not a pointer to char,
>not a string of characters, but a single char data item.
>
>You then specify an initial value for it which is not a single
>character. This is not wise...
(Leaving aside all the usual CLC bullshit - i.e., forget about the missing
stdio.h, blah, blah, blah), I think what the OP is actually fishing for
is something like this:
main() {
char p = '\x19';
printf("Value: %x\n",p);
}
Note that, AFAIK, there is no notation for specifying character
constants in decimal. So, to do it without the x's is a little tricky. | | | | re: print 19 on screen
On Jan 14, 7:14 pm, gaze...@xmission.xmission.com (Kenny McCormack)
wrote: Quote:
In article <fmfq1e$84...@aioe.org>,
Mark Bluemel <mark_blue...@pobox.comwrote:
>
>
> Quote:
asit wrote: Quote:
On Jan 14, 6:55 pm, Mark Bluemel <mark_blue...@pobox.comwrote:
>asit wrote:
>>On Jan 14, 6:19 pm, Mark Bluemel <mark_blue...@pobox.comwrote:
>>>asit wrote:
>>>>#include <stdio.h>
>>>>int main()
>>>>{
>>>> char p='19';
>> //write a statement to print 19 on screen
>> return 0;
>> }
>You snipped the vital part of my posting.
> Quote: Quote:
>What do you expect "char p='19';" to achieve?
> Quote: Quote:
i want to access 19 from p in GCC compiler ???
> Quote:
What you have coded states that p is a char, not a pointer to char,
not a string of characters, but a single char data item.
> Quote:
You then specify an initial value for it which is not a single
character. This is not wise...
>
(Leaving aside all the usual CLC bullshit - i.e., forget about the missing
stdio.h, blah, blah, blah), I think what the OP is actually fishing for
is something like this:
>
main() {
char p = '\x19';
printf("Value: %x\n",p);
}
>
Note that, AFAIK, there is no notation for specifying character
constants in decimal. So, to do it without the x's is a little tricky.
THANK YOU.....finally i got the answer | | | | re: print 19 on screen
In article <87r6gkpajw.fsf@kvetch.smov.org>,
Keith Thompson <kst-u@mib.orgwrote:
.... Quote:
>(If you're going to be participating here, you should know that Kenny
>McCormack is a troll; you'll be better off if you ignore everything he
>writes. Don't take my word for it; take a look at his posting
>history. I expect he'll post some stupid personal insult in response
>to this.)
Give it up, Keithy. We were all playing a round of "Read the OP's mind"
and the fact is, I won. Just admit it like a man.
You have to look at these kinds of posts as puzzles, and leave all the
usual CLS BS at the door. | | | | re: print 19 on screen
On 14 Jan 2008 at 23:51, Kenny McCormack wrote: Quote:
In article <87r6gkpajw.fsf@kvetch.smov.org>,
Keith Thompson <kst-u@mib.orgwrote:
... Quote:
>>(If you're going to be participating here, you should know that Kenny
>>McCormack is a troll; you'll be better off if you ignore everything he
>>writes. Don't take my word for it; take a look at his posting
>>history. I expect he'll post some stupid personal insult in response
>>to this.)
>
Give it up, Keithy. We were all playing a round of "Read the OP's mind"
and the fact is, I won. Just admit it like a man.
It's the sort of petulance you expect from CLC - he couldn't bring
himself to say, even through gritted teeth, that Kenny's practical
common sense had actually helped the OP, while the regulars' pedantic
literalism had failed to help the OP... And then this silly troll
name-calling (where troll = someone whose views differ from one's own)
replaces sensible discussion.
I think Godwin's Law applies in this group, with s/Nazi/troll/. | | | | re: print 19 on screen
In article <slrnfoou46.k3i.nospam@nospam.invalid>,
Antoninus Twink <nospam@nospam.invalidwrote: Quote:
>On 14 Jan 2008 at 23:51, Kenny McCormack wrote: Quote:
>In article <87r6gkpajw.fsf@kvetch.smov.org>,
>Keith Thompson <kst-u@mib.orgwrote:
>... Quote:
>>>(If you're going to be participating here, you should know that Kenny
>>>McCormack is a troll; you'll be better off if you ignore everything he
>>>writes. Don't take my word for it; take a look at his posting
>>>history. I expect he'll post some stupid personal insult in response
>>>to this.)
>>
>Give it up, Keithy. We were all playing a round of "Read the OP's mind"
>and the fact is, I won. Just admit it like a man.
>
>It's the sort of petulance you expect from CLC - he couldn't bring
>himself to say, even through gritted teeth, that Kenny's practical
>common sense had actually helped the OP, while the regulars' pedantic
>literalism had failed to help the OP...
Quite so. (channelling he who cannot be named) Quote:
>And then this silly troll name-calling (where troll = someone whose
>views differ from one's own) replaces sensible discussion.
Yes. Quote:
>I think Godwin's Law applies in this group, with s/Nazi/troll/.
Excellent point. And in the classical sense of Godwin's law (the
non-pejorative sense - in which the probability approaches 1 over time). | | | | re: print 19 on screen
"asit" <lipun4u@gmail.comwrote in message
news:3322f292-0068-4841-a52d-d765cc705acd@i3g2000hsf.googlegroups.com... Quote:
#include <stdio.h>
>
int main()
{
char p='19';
-----------------
return 0;
}
>
>
can anyone tell me what is the missing statement by writing which 19
will be printed on screen ???
int main()
{
char p[3]="19";
printf ("%s\n", p);
return 0;
} | | | | re: print 19 on screen
On Sat, 15 Mar 2008 16:19:32 -0700,Mabden wrote: Quote:
"asit" <lipun4u@gmail.comwrote in message
news:3322f292-0068-4841-a52d-d765cc705acd@i3g2000hsf.googlegroups.com... Quote:
>#include <stdio.h>
>>
>int main()
>{
> char p='19';
> -----------------
> return 0;
>}
>>
>>
>can anyone tell me what is the missing statement by writing which 19
>will be printed on screen ???
>
int main()
{
char p[3]="19";
printf ("%s\n", p);
return 0;
}
puts("19");
Isn't this one simpler?
--
Hi, I'm a .signature virus, please copy/paste me to help me spread
all over the world. | | | | re: print 19 on screen
WANG Cong <xiyou.wangcong@gmail.comwrites: Quote:
On Sat, 15 Mar 2008 16:19:32 -0700,Mabden wrote: Quote:
>"asit" <lipun4u@gmail.comwrote in message
>news:3322f292-0068-4841-a52d-d765cc705acd@i3g2000hsf.googlegroups.com... Quote:
>>#include <stdio.h>
>>>
>>int main()
>>{
>> char p='19';
>> -----------------
>> return 0;
>>}
>>>
>>>
>>can anyone tell me what is the missing statement by writing which 19
>>will be printed on screen ???
>>
>int main()
>{
> char p[3]="19";
> printf ("%s\n", p);
> return 0;
>}
>
puts("19");
>
Isn't this one simpler?
This and other solutions were discussed at some length when the
original question was posted 2 months ago. I'm not sure why Mabden
has decided to resurrect the old thread.
--
Keith Thompson (The_Other_Keith) <kst-u@mib.org>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister" |  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,418 network members.
|