Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I print a character array, via printf, 1 element at a time?

Status
Not open for further replies.

phoenix2

Programmer
Feb 25, 2006
1
US
I am just starting out in C and am trying to create a function to receive an array, and then print it to the screen, 1 element at a time. I am having no joy at all. I can do it with an int array but not a char array.<br>&nbsp;<br>
 
How about:<br><br><FONT FACE=monospace>char my_array[10];<br><br>...<br><br>for (lc=0; lc&lt;10; lc++)<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;printf(&quot;%c\n&quot;,my_array[lc]);<br>}</font><br><br>Hope that helps (and that I didn't make a silly mistake..)<br>Loon<br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top