Writing to a file, etc

Discussion in 'C' started by ShinigamiCooper, Sep 1, 2010.

  1. ShinigamiCooper

    ShinigamiCooper New Member

    Sep 1, 2010
    Likes Received:
    Trophy Points:
    So I'm not new at coding, I'm just not very good. So when I run into problems, my codes get really funky and I'm at that point where someone needs to help me and I'd really appreciate it. I'm trying to write something that at 3:00 every day, this program will print a new list of Spanish verbs to conjugate, and the verbs change daily. I haven't even gotten to the printing part, I'm stuck at having it write to a file. Again, I'm really, really bad at writing code, so don't judge me by this! Sometimes I make cool things too haha. Also if you can explain to me in technical terms and then computer illiterate terms that would be so helpful. Oh and my pathetic attempt at getting it to write to a file is under tuesday...because today is tuesday.

    char hablar[7];
    char decir[7];
    char ir[7];
    char ser[7];
    char estar[7];
    char poner[7];
    int file_number = 0;
    int main(int argc, char *argv[])
        //File coding
        FILE *out_file;
        out_file = fopen("spanishpractice.txt","a+"); 
        //What day code
        time_t seconds;
        struct tm *now;
        seconds = time(NULL);
        now = localtime(&seconds);
        const char *days[] = {"Sunday", "Monday", "Tuesday", "Wednesday",
        //Possible Verbs
        //Day specifics
        if(days[now->tm_wday] = "Sunday")
        if(days[now->tm_wday] = "Monday")
        if(days[now->tm_wday] = "Tuesday")
         fprintf(out_file,"%s",hablar);//trying to write the verb "hablar" to spanishpractice.txt
        if(days[now->tm_wday] = "Wednesday")
        if(days[now->tm_wday] = "Thursday")
        if(days[now->tm_wday] = "Friday")
        if(days[now->tm_wday] = "Saturday")
    So I'm sure you probably cringed a billion times while reading that, but I need to know why isn't it writing to the file? The file constantly remains blank, and if you can think of a better way to do anything right now I'd be glad to hear it! The code isn't finished yet, so thats why you see the skeleton of it, its how I work, probably a bad habit. Anyway, I'd really appreciate some help!

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