小编Sch*_*ami的帖子

realloc(): 无效的下一个大小 - realloc 动态结构

我开始学习 C 中的 struct 。今天我发现了一个我无法解决的问题。我有这个代码:

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 …
Run Code Online (Sandbox Code Playgroud)

c struct realloc

1
推荐指数
1
解决办法
2101
查看次数

标签 统计

c ×1

realloc ×1

struct ×1