R
ramif_47
Hi,
I'm trying to create a buffer (struct) that holds an array of characters.
struct bufferType
{
char *data; //array of characters -- not string
};
The buffer is initialized without any problems, but when I try to store a
character in the first location (of data), the following error appears:
"test.c:20: error: expected identifier before ‘(’ token"
Can any one figure out what does this error means?
BTW here is my code:
#include <stdio.h>
#include <stdlib.h>
struct bufferType
{
char *data; //array of characters -- not string
};
typedef struct bufferType buffer;
main()
{
buffer *buf = malloc(sizeof(buffer));
buf->data = malloc(100 * sizeof(char));
buf->(*(data+0)) = 'a'; //here is where error occurs
return 0;
}
I'm trying to create a buffer (struct) that holds an array of characters.
struct bufferType
{
char *data; //array of characters -- not string
};
The buffer is initialized without any problems, but when I try to store a
character in the first location (of data), the following error appears:
"test.c:20: error: expected identifier before ‘(’ token"
Can any one figure out what does this error means?
BTW here is my code:
#include <stdio.h>
#include <stdlib.h>
struct bufferType
{
char *data; //array of characters -- not string
};
typedef struct bufferType buffer;
main()
{
buffer *buf = malloc(sizeof(buffer));
buf->data = malloc(100 * sizeof(char));
buf->(*(data+0)) = 'a'; //here is where error occurs
return 0;
}