473,394 Members | 1,781 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.

Printing ASCII Characters instead of Integers: Question(#)

8
I'm tyring to get the output of the Question # with last question at the end.

Here is the code: Instead of printing the # after the Question, it prints the ASCII Characters.

/* print question# (loop) */

#include <stdio.h>
#include <string.h>

main()
{
int q=5;
int n=0;
char name[3]="Jon";

TEST:
n++;
if ((n != q))
{printf ("Question %s\n",&n);

goto TEST;}
else
{printf ("Last Question, Good Luck" "%s" "!!",&name);
goto END_NOTEST;}

END_NOTEST:
printf ("Bye Bye");
}
Oct 29 '06 #1
1 3600
arne
315 Expert 100+
I'm tyring to get the output of the Question # with last question at the end.

Here is the code: Instead of printing the # after the Question, it prints the ASCII Characters.

/* print question# (loop) */

#include <stdio.h>
#include <string.h>

main()
{
int q=5;
int n=0;
char name[3]="Jon";

TEST:
n++;
if ((n != q))
{printf ("Question %s\n",&n);

goto TEST;}
else
{printf ("Last Question, Good Luck" "%s" "!!",&name);
goto END_NOTEST;}

END_NOTEST:
printf ("Bye Bye");
}
Instead of your line
Expand|Select|Wrap|Line Numbers
  1. {printf ("Question %s\n",&n);
  2.  
try this line
Expand|Select|Wrap|Line Numbers
  1. {printf ("Question %i\n",n);
  2.  
I replaced the '%s' with a '%i' (since you want to print an int, not a char string) and omitted the address operator '&' (since you do not want to print the address of 'n', but its value).
Oct 29 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Marian Aldenhövel | last post by:
Hi, I am very new to Python and have run into the following problem. If I do something like dir = os.listdir(somepath) for d in dir: print d The program fails for filenames that contain...
1
by: Ralph Noble | last post by:
Folks ... I have a pipe-delimited ASCII text file with a lot of different non-printing characters. Rather than try and figure out all the non-printing characters that exist in this 17+ million...
18
by: Ger | last post by:
I have not been able to find a simple, straight forward Unicode to ASCII string conversion function in VB.Net. Is that because such a function does not exists or do I overlook it? I found...
6
by: Friso Wiskerke | last post by:
Hi all, I'm creating a fixed length textfile with data which is sent out to a third-party which in turn reads the file and processes it. Some of the characters are not part of the lower ASCII...
25
by: mdh | last post by:
I wrote a little insignificant program, to help me write a more significant one!!...that was supposed to print all Ascii values from 0 to 127: >>>> #include <stdio.h> # define UPPER_LIMT 127...
5
by: Ross | last post by:
I have a quick question regarding printing string constants. When you printf() a string constant, how are the characters encoded that get sent to the standard output? Is it in the execution...
14
by: abhishekkarnik | last post by:
Hi, I am trying to read an exe file and print it out character by character in hexadecimal format. The file goes something like this in hexadecimal 0x4d 0x5a 0x90 0x00 0x03 .... so on When I...
4
by: meendar | last post by:
Hi, I am having a character pointer which contains ascii values. i just want to convert all these ascii values to respective characters and again store it in another character pointer. ...
1
by: Rui | last post by:
Hi, how can i do what Encoding.ASCII.GetBytes (in .net, c#) does with the strings. I am trying to query some dns server to check its response using udp sockets. Some of the source below: #...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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.