Write a single character in a file (c)

#include <stdio.h>

int main(void)
{
    char ch;
    FILE *p;
    //-----------------
    //write a character in file
    p = fopen("text.txt""w");
    printf("Enter a character to write on file ");
    ch = getchar();
    fputc(chp);

    fclose(p);

    //view the character in file
    p = fopen("text.txt""r");
    ch = fgetc(p);
    printf("A character in file is %c"ch);

    fclose(p);
}


SHARE

Milan Tomic

Hi. I’m Designer of Blog Magic. I’m CEO/Founder of ThemeXpose. I’m Creative Art Director, Web Designer, UI/UX Designer, Interaction Designer, Industrial Designer, Web Developer, Business Enthusiast, StartUp Enthusiast, Speaker, Writer and Photographer. Inspired to make things looks better.

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment