c program to read a string from a file

Write a c program to read a string from a file


<< Go to Index Page >>

3 comments:

  1. #include
    int main()
    {
    FILE *fp;
    char buff[255];
    fp=fopen("C:/test","r");
    fscanf(fp,"%s",buff);
    printf("%s\n",buff);
    return 0;
    }

    ReplyDelete
  2. #include
    #include
    int main()
    {
    FILE *fp;
    char ch[100];
    char buff;
    int i;
    fp=fopen("E:/FILE/salman.txt","r");
    while(fscanf(fp,"%c",&ch[i])!=EOF)
    {
    buff=ch[i];
    printf("%c",buff);
    }
    fclose(fp);
    return 0;
    }

    ReplyDelete