getting subscripted value is neither array nor pointer error
Code:
int get_circuit(void)
{
char buffer[100] = {0}; /* initialized to zeroes */
int i,a, rc;
float x;
char member0[10] = "test";
FILE *fp = fopen(FILE_NAME_IN,"r");
if (fp == NULL) {
perror("Failed to open file \"myfile\"");
return EXIT_FAILURE;
}
for (i = 0; (rc = getc(fp)) != EOF && i < 100; buffer[i++] = rc)
;
fclose(fp);
//print out the contents of buffer
for(i=0;i<10;i++)
{
printf("buffer[%i] = %c\n",i,buffer[i]);
if(buffer[i]==' ');
{
x = atoi(buffer);
a++;
}
printf("x = %f",x);
}
printf("ready to print the array");
getchar();
print_c_array(buffer);
strcpy(x[0].name,member0); //<- this is the line it refers to
return EXIT_SUCCESS;
}
The structure defined as a globlal
Code:
struct components
{
char name[20];
float value;
}x[10];
Thanks in advance, Mick