I've got this code:
Code:
#include <stdio.h>
#include <stdlib.h>
#define MAX_NUM 50
typedef struct{
char desc[15];
float price;
}Item;
typedef struct{
char name[15];
}Store;
Item Items[MAX_NUM];
Store Stores[MAX_NUM];
int main()
{
int i,j,k;
for(i = 0; i < 25; i++){
printf("Enter the name of the store: \n");
scanf("%s", Stores[i].name);
if(Stores[i].name == '\n')
break;
}
for(j = 0; j < 25; j++){
printf("Enter the description of the item: \n");
scanf("%s", Items[j].desc);
if(Items[j].desc == '\n')
break;
}
for(k = 0; k < 25; k++){
printf("Enter the price: \n");
scanf("%f", Items[k].price);
if(Items[k].price == '\n')
break;
}
system("PAUSE");
return 0;
}
Error message is:
[Warning] comparison between pointer and integer
It points to this part of the code:
Code:
if(Stores[i].name == '\n')
I don't understand why it telling me this message because i didn't use any pointers in my program?
I used three dimensional arrays to access the elements of the structures. I wanted program keeps looping so I can just enter data until I hit new line character.
Is this OK?
Thanks.