Hi guys I was thinking if I can assign pointer value to variable? Basically I have pointer that points to integer value and i want to assign it to another variable. Ie:
coursep->node = 1 //coursep is pointer to structure and node is structure variable
int var;
var = coursep->node; //I want variable to be 1
Can I do this? and how? It seems not to work when I try to assign it like this.
EDIT: Basically I am trying to put from pointer value to arrays or structures.
lines = lineCount(courses); //counts how many lines does file have
struct courses course[lines]; // creates array of structures with amount of lines
for (i = 0; i < lines; i++) {
struct courses *coursep;
coursep = course;
fscanf(co, " %c %d ", &coursep->courseName, &coursep->numberOfNodes);
course[i].courseName = coursep->courseName;
course[i].numberOfNodes = coursep->numberOfNodes;
for (j = 0; j < coursep->numberOfNodes; j++) {
fscanf(co, " %d", &(coursep->nodes[j]));
var = *coursep->nodes[j];
printf("%d\t", var);
}
fscanf(co, "\n");
}
Structure:
struct courses{
char courseName;
int numberOfNodes;
int nodes[];
};
I cant seem to put it straight into array, because it prints out random rubbish, if I use pointers it seems to show correct values (everything is read from file), but when I try to put it all into array it seems tho throw random rubbish again =/ any ideas?