Tuesday, July 28, 2009

Help wit putting C code in "functions"?

can anyone assit me in putting this code in functions? i have no idea how functions work. it suppose to be in three functions...fill array, print array and delte name. how do i do that?

Help wit putting C code in "functions"?
char main ()


{


char name [24] ;


char list [6] [24];


char dname [24];








printf("\nHello!, Please Enter Six Names of Your Choice");





for(int val = 0; val %26lt; 6; val++)


{


/* ***read the name*** */


scanf("%s", name);


/* copy the read name into the list of names */


for(int val2 = 0; val2 %26lt; 24; val2++)


list[val][val2] = name[val2];


}


void printArray(char list[])


{


printf("\n----------------------------...


printf("\n The names that you entered are:\n");


printf("------------------------------...





for (int i = 0 ; i %26lt; 6 ; i++ )


{


printf ( "%s\n", list[i] );


}


}





int deleteName(char list[], char dname)


{


printf("\nEnter the name you want deleted\n");


for(int count=0;count%26lt;=5;count++)


{


scanf("%s",%26amp; dname);


if (dname!= list[count])


{


printf("\n This name has been deleted: ""%s",dname);


}


}


return 0;


}


}


No comments:

Post a Comment