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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

input into record/array

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I am trying to input an ID number into a program and have it go to that particular ID and then input a series of numbers into an array that is present there...how would i go about doing this?

ID is a record and i need to refer to another field in this record which has an array in it, i need to enter values

hope you guys can help :)

Code:
void enter_numbers(number *ptr)
{
	int num,i,j,k=0,total;
	
	for(i=1;i<counter;i++,ptr++)
	{
		total=0;
		printf(&quot;\n\tEnter ID number&quot;);
		scanf(&quot;%d%&quot;,m);
		
		for(j=0;j<8;j++)
			{  
				printf(&quot;\n\tEnter the results for this ID&quot;,j);
	   			scanf(&quot;%d&quot;,&k);
		        ptr->score[j] = k;		
		   		total=+k;
			}
				ptr->total_score =total;
	
		
	}
}

 
When you say ID is a record... what do you mean? Is it something like this?:

Code:
struct ID
{
   double* numbers;
};

or is it like this:

Code:
struct info
{
   int ID;
   double* numbers;
};

Personally, I would set it up the second way. If you make ID the name of the structure, you lose the ability for users to access the record by that name.

With the second setup, you would create an array of &quot;info&quot; objects (info* list; would be the declaration) and then you could access each record by the following syntax:

Code:
list[n].ID;
list[n].numbers[m];

I'm not sure if I understood your problem correctly... if you could post a little more code, I might be able to figure it out a little better.

Ben
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top