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!

Exit a function

Status
Not open for further replies.

Mungovan

Programmer
Oct 24, 2002
94
IE
Hi.
I was wondering if anyone could help me?

Basically I have a function that takes in a struct pointer and returns a struct pointer to the main program. The function itself has a loop in it that loops through a global array.

I want the function to return one and only one struct to the main function when it finds it.

In other words:-
(grid[][] is a 2-D global array of struct pointers)

for(i=0;i<100<i++){
for(j=0;j<100;j++){

if(a certain condition is met){
return(grid[j]);
// exit??? to main program, returning only the
// first struct pointer it finds, and not looping
//through the rest and returning them.
}
}
}



Thanks.
D
 
The test should be for grid[j] and you should return return grid[j] instead of return grid[j];

Returning grid[j] will return an array of structs.
 
always creates italics if TGML processing box isn't checked, unless you surround your code with
Code:
 ..
Dickie Bird
Honi soit qui mal y pense
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top