Results 1 to 2 of 2

Thread: Getchar() problems

  1. #1

    Thread Starter
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772

    Getchar() problems

    PHP Code:
    FILE *pFile fopen("pw.txt""a");

    if (
    pFile != NULL)
    {
        for (
    int i 1<= stopi++)
        {
            
    //fprintf stuff
        
    }

        
    fclose(pFile);
        
    printf("Successfully written to file");
    }
    else
        
    printf("Could not open output file");

    getchar(); 
    I want to have the getchar() so the user has time to read what is being printed to the screen. The problem is, it only works if fopen() fails. If the file opens then it is as if getchar() isn't there. What's causing this?
    Alcohol & calculus don't mix.
    Never drink & derive.

  2. #2
    jim mcnamara
    Guest
    Try a code block:

    PHP Code:
    FILE *pFile fopen("pw.txt""a");

    if (
    pFile != NULL)
    {
        for (
    int i 1<= stopi++)
        {
            
    //fprintf stuff
        
    }

        
    fclose(pFile);
        
    printf("Successfully written to file");
    }
    else {
        
    printf("Could not open output file");
    }
    getchar(); 

Posting Permissions

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



Click Here to Expand Forum to Full Width