Hi, I 've been trying to compile a program that uses the following structure but i keep getting errors. What's wrong?
struct node
{
char map[3][3]={{0,0,0},{0,0,0},{0,0,0}};
struct node *father;
struct node *nextLev;
nextLev=NULL;
father=NULL;
};
Thanks in advance.
2 replies to this topic
#1
Posted 11 February 2012 - 05:27 PM
|
|
|
#2
Posted 11 February 2012 - 05:54 PM
struct node
{
char map[3][3];// = {{0,0,0},{0,0,0},{0,0,0}};
struct node *father;
struct node *nextLev;
};
I don't think you can do initialization in the structure definition? Someone can correct me if I'm wrong.
This compiles:
#include <stdio.h>
#include <stdlib.h>
struct node
{
char map[3][3];// = {{0,0,0},{0,0,0},{0,0,0}};
struct node *father;
struct node *nextLev;
};
int main()
{
struct node n;
int x;
int y;
for (x = 0; x < 3; x++) {
for ( y = 0; y < 3; y++) {
n.map[x][y] = 0;
}
}
return 0;
}
#3
Posted 14 February 2012 - 01:36 PM
Thanks, it was that. You cannot initialize structures in C.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









