C
Carramba
Hi!
I want to have a struct representing a table, with int's and float.
But I seem to get only stuckdump.. and not really sure why , hope you
can help!
Thanxk you in advance
#include <stdio.h>
#include <stdlib.h>
typedef struct {
int *t;
float *f;
} Table;
Table *tb;
int main(void) {
int size, i;
/* init table*/
size = 10;
/* allocate array for ints */
tb->t = malloc(size * sizeof*(tb->t));
/* allocate array for foats */
tb->f = malloc(size * sizeof *(tb->f));
/*fill ints*/
for(i=0;i<9;i++) {
tb->t= size;
size--;
}
/*fill floats*/
for(i=0;i<9;i++) {
tb->f= 0.01*(i+1);
}
for(i=0;i<10;i++) {
printf("tb->t[%d]=%d ;tb->f[%d]\n",i,tb->t,i,tb->f);
}
return EXIT_SUCCESS;
}
I want to have a struct representing a table, with int's and float.
But I seem to get only stuckdump.. and not really sure why , hope you
can help!
Thanxk you in advance
#include <stdio.h>
#include <stdlib.h>
typedef struct {
int *t;
float *f;
} Table;
Table *tb;
int main(void) {
int size, i;
/* init table*/
size = 10;
/* allocate array for ints */
tb->t = malloc(size * sizeof*(tb->t));
/* allocate array for foats */
tb->f = malloc(size * sizeof *(tb->f));
/*fill ints*/
for(i=0;i<9;i++) {
tb->t= size;
size--;
}
/*fill floats*/
for(i=0;i<9;i++) {
tb->f= 0.01*(i+1);
}
for(i=0;i<10;i++) {
printf("tb->t[%d]=%d ;tb->f[%d]\n",i,tb->t,i,tb->f);
}
return EXIT_SUCCESS;
}