Any cool function to replace readln from pascal in ansi c?

99封情书 提交于 2019-12-02 04:20:52

You can use scanf with a scanset conversion something like this:

char buffer[256];
scanf("%255[^\n]", buffer);

another possibility is to use fgets:

char buffer[256];
fgets(buffer, sizeof(buffer), stdin);

On Linux (and other POSIX-ish systems) you should probably also have a function named (surprise, surprise) readline that's similar, but will allocate the space necessary for the incoming data.

From here there is fgets that does this.

Yes.

char * fgets ( char * str, int num, FILE * stream );

Use fscanf function.

Are you looking for something like this.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!