Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,132 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,801 people online right now. Registration is fast and FREE... Join Now!




Character Input

 
Reply to this topicStart new topic

Character Input

silvert122
28 Mar, 2007 - 07:19 AM
Post #1

New D.I.C Head
*

Joined: 19 Mar, 2007
Posts: 17


My Contributions
Write a C program that uses the getc() function to accept a single character of input.
The program should then report the character that was entered, the ascii value and the hexadecimal value of the character on a single line.


#include <stdio.h>

/* copy input to output */

int main()
{
int c;
int an;

c = getchar();

while( c!= an)
{
putchar©;
c = getchar();
}
return 0;
}

im trying to put the an as sentinel value but it doesn t work
User is offlineProfile CardPM
+Quote Post

Fygar
RE: Character Input
28 Mar, 2007 - 07:21 AM
Post #2

I liek milk!!1
Group Icon

Joined: 28 Mar, 2002
Posts: 4,313


Dream Kudos: 50
My Contributions
moved to C/C++
User is offlineProfile CardPM
+Quote Post

Thorian
RE: Character Input
28 Mar, 2007 - 07:24 AM
Post #3

Pirate Medic
Group Icon

Joined: 6 Jun, 2002
Posts: 5,742



Thanked: 4 times
Dream Kudos: 275
My Contributions
Fygar is just kidding he does not have that ability however I do

Moved. to c++
User is offlineProfile CardPM
+Quote Post

Amadeus
RE: Character Input
28 Mar, 2007 - 07:33 AM
Post #4

g++ -o drink whiskey.cpp
Group Icon

Joined: 12 Jul, 2002
Posts: 12,226



Thanked: 37 times
Dream Kudos: 25
My Contributions
You have not assigned any value to the variable an - as such, it contains no valid data to compare against.
User is offlineProfile CardPM
+Quote Post

Wild_Rose
RE: Character Input
14 May, 2007 - 02:58 PM
Post #5

New D.I.C Head
*

Joined: 13 Apr, 2007
Posts: 39


My Contributions
have you seen this http://www.cplusplus.com/reference/clibrary/cstdio/getc.html ?
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/1/08 10:27PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month