Link to home
Start Free TrialLog in
Avatar of jango_ms
jango_ms

asked on

C array doubt== Urgent

Hello experts,

            I am stuck in  a situation here, more due to my inexperience in c.

I have two API functions . The first API function wll return a certain number of names.
I have to apply the second function on these names. This second function will give me back whether
there are nick names for that name ( true-if nick name exist; false-if nick nick doesn't exist)
So I wnat back those names which has a nick name........


I have some idea , please check whther it will work

array 1 ==> get the values from function1

on each value on array1 apply function2

return those values for whcih function2 returns true....


If this will work, please give me the code for this one.......

If not provide me another logic.......
Code snippets are greatly preferred.Early responses are greatly appreciated


Thanks in Advance

Jango........
Avatar of jhshukla
jhshukla
Flag of United States of America image

bool nick[sizeof(array1)/sizeof(array1[0])]; //basically number of elements
i think you would prefer to declare it as bool nick[PREDEFINED_SIZE];

void function2(bool nick[], int num){
  for (i=0; i<num; i++)
    if(nickname_if_found)
      nick[i] = true;
    else nick[i] = false;
}

i don't know where your names are stored so i can't help you with function1.

jaydutt
Avatar of sunnycoder
Declare an array of pointers and fill it with those entries in the actual array which have corresponding nick names. Return this array
ASKER CERTIFIED SOLUTION
Avatar of sunnycoder
sunnycoder
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial