473,394 Members | 1,701 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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 ???

Jan 14 '08 #1
17 1399
asit wrote:
#include <stdio.h>

int main()
{
char p='19';
What do you expect this to do?
Jan 14 '08 #2
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;
}

Jan 14 '08 #3
In article <33**********************************@i3g2000hsf.g ooglegroups.com>,
asit <li*****@gmail.comwrote:
>#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
Jan 14 '08 #4
On Jan 14, 6:16 pm, asit <lipu...@gmail.comwrote:
#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
Jan 14 '08 #5
In article <a3**********************************@t1g2000pra.g ooglegroups.com>,
asit <li*****@gmail.comwrote:
>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
Jan 14 '08 #6
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?
Jan 14 '08 #7
Richard Tobin wrote:
In article <a3**********************************@t1g2000pra.g ooglegroups.com>,
asit <li*****@gmail.comwrote:
>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;
}
Jan 14 '08 #8
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.

What do you expect "char p='19';" to achieve?

i want to access 19 from p in GCC compiler ???
Jan 14 '08 #9
asit wrote:
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.

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...
Jan 14 '08 #10
In article <fm**********@aioe.org>,
Mark Bluemel <ma**********@pobox.comwrote:
>asit wrote:
>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.

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.

Jan 14 '08 #11
On Jan 14, 7:14 pm, gaze...@xmission.xmission.com (Kenny McCormack)
wrote:
In article <fmfq1e$84...@aioe.org>,
Mark Bluemel <mark_blue...@pobox.comwrote:
asit wrote:
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.
>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.


THANK YOU.....finally i got the answer
Jan 14 '08 #12
In article <87************@kvetch.smov.org>,
Keith Thompson <ks***@mib.orgwrote:
....
>(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.

Jan 14 '08 #13
On 14 Jan 2008 at 23:51, Kenny McCormack wrote:
In article <87************@kvetch.smov.org>,
Keith Thompson <ks***@mib.orgwrote:
...
>>(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/.

Jan 15 '08 #14
In article <sl*******************@nospam.invalid>,
Antoninus Twink <no****@nospam.invalidwrote:
>On 14 Jan 2008 at 23:51, Kenny McCormack wrote:
>In article <87************@kvetch.smov.org>,
Keith Thompson <ks***@mib.orgwrote:
...
>>>(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)
>And then this silly troll name-calling (where troll = someone whose
views differ from one's own) replaces sensible discussion.
Yes.
>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).

Jan 15 '08 #15
"asit" <li*****@gmail.comwrote in message
news:33**********************************@i3g2000h sf.googlegroups.com...
#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;
}
Mar 15 '08 #16
On Sat, 15 Mar 2008 16:19:32 -0700,Mabden wrote:
"asit" <li*****@gmail.comwrote in message
news:33**********************************@i3g2000h sf.googlegroups.com...
>#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.
Mar 16 '08 #17
WANG Cong <xi************@gmail.comwrites:
On Sat, 15 Mar 2008 16:19:32 -0700,Mabden wrote:
>"asit" <li*****@gmail.comwrote in message
news:33**********************************@i3g2000 hsf.googlegroups.com...
>>#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) <ks***@mib.org>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Mar 16 '08 #18

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

48
by: David J Patrick | last post by:
I'm trying to rewrite the CSS used in http://s92415866.onlinehome.us/files/ScreenplayCSSv2.html. using the w3.org paged media standards as described at http://www.w3.org/TR/REC-CSS2/page.html ...
0
by: melanieab | last post by:
Hi, I have a tabpage with a print button. This button tries to do a print screen, and it works fine the first time, but if I try to press print again, I get error: An unhandled exception of type...
22
by: stephen | last post by:
I have created an order form that users javascript to create a new html document when the customers clicks the "print page" button. Once the new document has been created it then prints the...
2
by: Brad Pears | last post by:
I have a vb.net 2005 application and am using the print preview screen. This screen has a printer icon on it that the user can use to print the document currently being viewed. It uses the default...
1
by: tdartt | last post by:
Howdy! I'm fairly new to using css. I have two style sheets: <LINK href="printstyle.css" type="text/css" rel="stylesheet" media="print"> Which has (for example): .dgAltLine { display: none;...
4
by: william.oram | last post by:
alt.html pointed me here, so... I have two CSS files for print and screen. In screen.css: ..screen { font-weight:bold; font-size:12px; }
3
by: Max58kl | last post by:
Trying to access data and print it to the screen using Perl Builders I/O Window -------------------------------------------------------------------------------- Hi I am using a program called...
5
by: bdy120602 | last post by:
Is it possible, when a user or viewer of your Web page, prints or takes a screen shot of a Web page with mousover (roll-over) text in it, to have that text printed or captures as part of the screen...
4
by: Robson Felix | last post by:
It may sound like a silly question, but I would like to print a form or component from within Visual Studio when designing such form component. Is that possible?
10
by: Ed Jay | last post by:
I do not want to load two style sheets for screen and print media. I'm having difficulty grasping the use of the @print statement, or its syntax. Would someone please provide a simple explanation....
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.