0

I'm a newbie programmer

//allocating space for final output
//text_count is given by another function, let's just say i have a value for it
//out is my typedef struct

out *fin[text_count];

for(i=0; i<text_count; i++){
  fin[i] = malloc(sizeof(out));
}

//this is a test
fin[1]->appearances = 1;

printf("%d",fin[1]->appearances);

// ..other code

I noticed that after this allocation, program suddenly outputs this:

1_

The underscore is blinking, indicating it needs an input.

What can be my problem here? Is it the allocation? Or the codes down below?

okay sorry, let me clarify this, im using codeblocks . so when i get a blinking cursor it means it needs an input. and after i got this output, an infinite loop of inputs seems to be happening.

4

2 回答 2

3

您只是看到文本终端的光标。它可能在闪烁,也可能不闪烁,这本身并不意味着什么。

您可能需要添加换行符:

printf("%d\n", fi[1]->appearances);

在自己的一行上获得输出。

于 2013-03-13T12:22:47.607 回答
0

printf 后面的光标并不意味着它正在等待输入。

strace如果它正在等待read系统调用,您可以使用 来确认这一点。

用法: strace ./myApplication arg1 arg2...

于 2013-03-13T12:32:43.670 回答