Find the answer to your Linux question:
Results 1 to 2 of 2
http://download.videolan.org/pub/vid...31222.tar.gzhi , this is the code for Input/Output functions in C: #include <stdio.h> main() { FILE *fp; char s[80]; fp=fopen("POEM.TXT","w"); if(fp==NULL) { puts("Cannot open file\n"); exit(0); } printf("Enter a few ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Apr 2004
    Posts
    46

    error coding Input/output functions in C


    http://download.videolan.org/pub/vid...31222.tar.gzhi,
    this is the code for Input/Output functions in C:
    #include <stdio.h>
    main()
    {
    FILE *fp;
    char s[80];

    fp=fopen("POEM.TXT","w");
    if(fp==NULL)
    {
    puts("Cannot open file\n");
    exit(0);
    }
    printf("Enter a few lines of text:\n");
    while(strlen(gets(s))>0)
    {
    fputs(s,fp);
    fputs("\n");
    }
    fclose(fp);
    }
    and this is compilation error:
    [root@localhost i-o]# gcc -o l344 l344.c
    l344.c: In function `main':
    l344.c:17: error: too few arguments to function `fputs
    plz point me where is the mistake.

  2. #2
    Linux Engineer
    Join Date
    Sep 2003
    Location
    Knoxhell, TN
    Posts
    1,078
    it's the second call to puts().. you didn't specify a file stream for it to output to.. try changing it to just puts()..

    also, when posting code, please use the "code" tags.. it makes it *much* easier to read..
    Their code will be beautiful, even if their desks are buried in 3 feet of crap. - esr

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •