realloc(): invalid next size - realloc dynamic struct
问题 I started learning about struct in C. Today I found a problem, that I can't solve. I have this code: typedef struct fraze { char *mostSearch = NULL; // for string from user double freq; } s_FRAZE; int readFraze( ) { int i = 2, k; size_t len = 0; char c; s_FRAZE *s; s = (s_FRAZE *)malloc( i * sizeof( int )); k = 0; while( (c = getchar()) != '\n') { ungetc( c, stdin ); if( scanf( "%lf%c", &s[k].freq, &c) != 2 || c != ':' ) { return 1; } if( k + 1 >= i ) { i *= 2; printf("%d\n", i ); s = (s