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 25-Sep-2009, 07:48
veda veda is offline
New Member
 
Join Date: Sep 2009
Posts: 1
veda is on a distinguished road

Struct array - char array


Hello,

I am trying to run the following code (on a NDS gameconsole) but it doesn't run for some reason. Can anyone tell me what i am doing wrong?

CPP / C++ / C Code:
	struct node
	{  	char title[26];
		char description[201];       
		char datum[21];
	};

	struct node nodes[10];
	
	nodes[0].title[0]='t';
	nodes[0].title[1]='i';
	nodes[0].title[2]='t';
	nodes[0].title[3]='l';
	nodes[0].title[4]='e';
	nodes[0].title[5]='1';
	nodes[0].title[6]='\0';
	nodes[1].title[0]='t';
	nodes[1].title[1]='i';
	nodes[1].title[2]='t';
	nodes[1].title[3]='l';
	nodes[1].title[4]='e';
	nodes[1].title[5]='2';
	nodes[1].title[6]='\0';
	
	sprintf("%s\n",nodes[0].title);
	sprintf("%s\n",nodes[1].title);
(this is just a snippet)

Thanks

Veda
Last edited by LuciWiz : 27-Sep-2009 at 12:50. Reason: Please insert your C code between [cpp] & [/cpp] tags
  #2  
Old 25-Sep-2009, 08:17
fakepoo fakepoo is offline
Regular Member
 
Join Date: Oct 2007
Posts: 713
fakepoo is a jewel in the roughfakepoo is a jewel in the roughfakepoo is a jewel in the rough

Re: Struct array - char array


You are using sprintf() at the end to (what looks like to me, anyway) print the strings out to the screen when you should just use printf().

Also, on a side note, try using sprintf() to populate the strings within your struct:

sprintf(nodes[0].title, "title1");
 
 

Recent GIDBlogAccepted for Ph.D. program by crystalattice

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
Str_Misaligned in Double Link List Peter_APIIT C Programming Language 1 29-Feb-2008 21:50
Warning: comparison is always false due to limited range of data type nasim751 Computer Software Forum - Linux 1 30-Jan-2008 22:19
No output after compile nasim751 Computer Software Forum - Linux 1 29-Jan-2008 10:28
Pointer initialization causing program abend? emanresu C Programming Language 0 12-Dec-2006 11:36
Debug Assertion Failed! dlare9 C Programming Language 3 14-Nov-2005 00:18

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

All times are GMT -6. The time now is 02:40.


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