i want to print this array of countries but when are two countries same i want to print it just once. countries are already ordered alphabeticaly any ides ???
for(b=0;b<v;b++){
if(strcmp(country[b-1],country[b]) !=0){
printf("%s",country[b]);}
}
v is number of countries
Allocate a 2 dimensional character array dynamically for krajina.
Refer this question:
2 Dimensional Memory Allocation
EDIT: Elaboration:
Alright. You said you can count the number of countries. Say you store that in a variable called
countok?Now you need to allocate a 2D character array with
countnumber of rows and 31 columns right? You do this as follows.Now you have the
countryvariable which you can use normally like how you would use a 2d char array (like youve used in your code)