-2
I need to make a query in a struct and compare all the .Location to print only 1 time without repetition, each one with their respective stored values.
struct archive{
char Title[N];
char autorName[N];
char pCompany[N];
char location[N];
int amount;
int releaseDate;
int edition;
int isbn;
};
My attempts to carry out this action have failed, here is an example:
// listar cada local separadamente
for(int i=0; i < quant+countBook; i++){
if(strcmp(book[i].location, book[i].location) == 0){
printf("%s\n", book[i].location);
}
}
If although there may be repetitions you want to print only one then to find the first one. Now this
(strcmp(book[i].location, book[i].location) == 0)
will always be true since I can’t imagine how anything can be different from himself.– anonimo
I agree, but it was the first thing that came to mind, although I tried to use another loop for then changing the second argument from strcmp() to j and likewise did not work. And the goal of this function is: to list the vectors of the struct in order by Location, and should not print twice or more the same Location since at first impression already show all the data related to it.
– rizzo1896