Im going through a list of names(namn[m]) and I want to compare them with a few other names (tankbaraNamn[k]).....now my problem is:
if a name, in the array tankbaraNamn[k], can't be found in the array, name[m], I want the program to simply print the name which couldn't be found (tankbaraNamn[k] and say that it's not in the list. My strcpy isn't working though, I get error messages whenever I try to copy a specific part of the array(tankbaraNamn[k] to another string(tempNamn)..I don't know how to solve this...can anyone please help me?
Im using the program Dev-C++.
NOTE: tankbaraNamn[k] and tempNamn are declared:
char tankbaraNamn[5][15], tempNamn[15];
tankbaraNamn[k] has previously in the code scanned the strings which should be located there (and it works as it should)
//start on error--------------------------------
for(k=0;k<poster;k++)
for(m=0;m<100;m++)
{
if((strcmp(tankbaraNamn[k], namn[m])==0))
{
hittat=1;
printf("%s finns p? plats %d\n",tankbaraNamn[k], m);
}
else
{
strcpy(tempNamn, tankbaraNamn[k]);
hittat=0;
}
if(hittat==0)
printf("%s finns inte med p? listan\n", tempNamn);
else
;
}
Question
CbbLe
Im going through a list of names(namn[m]) and I want to compare them with a few other names (tankbaraNamn[k]).....now my problem is:
if a name, in the array tankbaraNamn[k], can't be found in the array, name[m], I want the program to simply print the name which couldn't be found (tankbaraNamn[k] and say that it's not in the list. My strcpy isn't working though, I get error messages whenever I try to copy a specific part of the array(tankbaraNamn[k] to another string(tempNamn)..I don't know how to solve this...can anyone please help me?
Im using the program Dev-C++.
NOTE: tankbaraNamn[k] and tempNamn are declared:
char tankbaraNamn[5][15], tempNamn[15];
tankbaraNamn[k] has previously in the code scanned the strings which should be located there (and it works as it should)
//start on error--------------------------------
//end of code------------------------------------
plz help a poor gu:(:(
Link to comment
Share on other sites
13 answers to this question
Recommended Posts