Copy characters from a file into C programs

Discussion in 'C' started by Mitu Gabriel Cristian, Feb 23, 2019.

Tags:
  1. Mitu Gabriel Cristian

    Mitu Gabriel Cristian New Member

    Joined:
    Feb 15, 2019
    Messages:
    2
    Likes Received:
    1
    Trophy Points:
    1
    Gender:
    Male
    please, I have next code:
    Code:
    #include <stdio.h>
    
    void main(void)
    {
    FILE *etc
    etc=fopen("\\adress_of_file","r");
    char caracter;
    int a;
    char sir[60];
    for(a=0;character=fgetc(etc);i++)
    sir[I]=character;
    }
    
    //This code after run gave me something very strange like: %^@#^+&*^%
    //I don't understand, function's type fgetc() is int but I want copy a text from file into string rename char sir[60] and I change character=fgetc(etc), character is a char variable.
    //please, give me a solution![/I]
     
    cprogrammingbooks likes this.
  2. Mitu Gabriel Cristian

    Mitu Gabriel Cristian New Member

    Joined:
    Feb 15, 2019
    Messages:
    2
    Likes Received:
    1
    Trophy Points:
    1
    Gender:
    Male
    sir=character after for, excuse-me. I don't know how can I edit my text.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice