GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 10-Jun-2005, 09:31
Error's Avatar
Error Error is offline
Junior Member
 
Join Date: May 2005
Posts: 42
Error is on a distinguished road

Displaying data


I'm trying to output data using nested for loops to display the content of 2D character arrays as follows
CPP / C++ / C Code:
void display()
{
	printf("Processing\n");


	for(i = 0; i = 20; i++)
	{
		for(j=0; j=11; j++) 
			printf("%c", name[j][i]);

		printf("\t");

		for(j=0; j=50; j++) 
			printf("%c", quest[j][i]);
		
		printf("\t");

		for(j=0; j=10; j++) 
			printf("%c", color[j][i]);

		printf("\t");
	} 
	printf("Print sucessful\n");
}
When I activate the function while running the program, I get an endless stream of spaces. Does anyone know what I'm doing wrong?
  #2  
Old 10-Jun-2005, 09:58
maprich maprich is offline
Member
 
Join Date: May 2005
Posts: 163
maprich has a spectacular aura aboutmaprich has a spectacular aura about
Quote:
Originally Posted by Error
CPP / C++ / C Code:
...
	for(i = 0; i = 20; i++)
	{
...
		printf("\t");
	} 
...
You have misunderstood the syntax of for statement. Please check the corrects syntax from web.
You probably want the for statement to be
CPP / C++ / C Code:
for(i=0; i<=20; i++ )
{
    // etc
}
  #3  
Old 10-Jun-2005, 10:33
Error's Avatar
Error Error is offline
Junior Member
 
Join Date: May 2005
Posts: 42
Error is on a distinguished road
It is working now. thank you
  #4  
Old 10-Jun-2005, 11:48
Dave Sinkula Dave Sinkula is offline
Member
 
Join Date: Apr 2005
Posts: 199
Dave Sinkula will become famous soon enough
Quote:
Originally Posted by maprich
You have misunderstood the syntax of for statement. Please check the corrects syntax from web.
You probably want the for statement to be
CPP / C++ / C Code:
for(i=0; i<=20; i++ )
{
    // etc
}
I would think it might be like this.
CPP / C++ / C Code:
for ( i = 0; i < 20; i++ )
{
    // etc
}
  #5  
Old 10-Jun-2005, 12:04
maprich maprich is offline
Member
 
Join Date: May 2005
Posts: 163
maprich has a spectacular aura aboutmaprich has a spectacular aura about
Dave: Yes why not.
<20 makes the length a round number but it's still just guessing since you don't know what the original poster exactly wanted.
The point is that the original poster now understands to learn the correct syntax.

Nice to flimflam like this about inconsequential matters
Increases neatly our posts counter
  #6  
Old 10-Jun-2005, 12:11
Dave Sinkula Dave Sinkula is offline
Member
 
Join Date: Apr 2005
Posts: 199
Dave Sinkula will become famous soon enough
Quote:
Originally Posted by maprich
Dave: Yes why not.
<20 makes the length a round number but it's still just guessing since you don't know what the original poster exactly wanted.
The point is that the original poster now understands to learn the correct syntax.
I point it out because it is a very common error: going off the end of the array, undefined behavior, all that ("inconsequential" indeed).

Quote:
Originally Posted by maprich
Nice to flimflam like this about inconsequential matters
Increases neatly our posts counter
It appears to be just that for this last post of yours.
  #7  
Old 10-Jun-2005, 12:38
maprich maprich is offline
Member
 
Join Date: May 2005
Posts: 163
maprich has a spectacular aura aboutmaprich has a spectacular aura about
Quote:
Originally Posted by Dave Sinkula
I point it out because it is a very common error: going off the end of the array, undefined behavior, all that ("inconsequential" indeed).
Ok sorry, I take that back. Makes sense when you explain it from your point of view.
 
 

Recent GIDBlogVista ?Widgets? on Windows XP by LocalTech

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Include] Doubly-linked List dsmith C Programming Language 6 14-Apr-2006 13:12
Mrs stacy12 C Programming Language 14 05-Feb-2005 18:02
[GIM] gim.h dsmith C Programming Language 0 18-Jan-2005 08:48
[CONTEST?]Data Structure Test dsmith C Programming Language 2 06-Jun-2004 15:13

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 22:03.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.