小编use*_*696的帖子

fgets doesnt get the last character

for some reason, when I print phrase in the following code I discover that the fgets function doesn't get the last characater in the text file. I already checked mone1 and saw that its given enough space for the text in the file. Does someone have an explanation and a soloution to that occurrence?

Tnx, Dean.

ps我很确定字符串的长度不是问题,因为即使我将它更改为2个字符它仍然只打印第一个字符(不打印最后一个字符),并且它们都写在同一行.

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char * argv[])
{
    printf("ss");
    FILE * sent=NULL;
    FILE * voca=NULL;
    sent=fopen(argv[1],"r");
    voca=fopen(argv[2],"r");
        if(voca==NULL){
        printf("cannot open …
Run Code Online (Sandbox Code Playgroud)

c string file-io fgets char

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

标签 统计

c ×1

char ×1

fgets ×1

file-io ×1

string ×1