public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: "Steven I. Pollmann" <spollman@julian.uwo.ca>
To: gnu-win32@cygnus.com
Subject: gcc and file reading HELP!!
Date: Sun, 26 Oct 1997 12:46:00 -0000	[thread overview]
Message-ID: <199710262046.PAA17818@romeo.its.uwo.ca> (raw)

        Sorry about the message, but I'm having a problem with my "c"
program reading lines of text from a file with gnu-win32.  The file compiles
fine, but when it executes, 
the lines are displayed, and then stack errors are reported to the screen at
the end, terminating the program.  The program appears to work fine on the
Unix operating system we have at school.  Please help, I'd like to get this
working with windows.

here is the program:

#include <stdio.h>
#define maxFilename 40

int main()
{
int OpenFile(FILE **filePoint, char fileName [maxFilename]);
void CloseFile(FILE **filePoint);
void PrintFileContents(FILE **filePoint);

char userFile[maxFilename];
FILE *sourcefp;


   printf("Enter a file to open: \n");
   scanf("%s",userFile);
   printf("file \"%s\" is being opened...",userFile);
   
   if (OpenFile(&sourcefp, userFile) == 1)
   {
      printf("file \"%s\" opened.\n",userFile); 
      
      PrintFileContents(&sourcefp);

      CloseFile(&sourcefp);
      printf("file \"%s\" closed.\n",userFile);
   }

return 0;
}


/* open file for reading */

int OpenFile(FILE **filePoint, char fileName [maxFilename])
{
   if ((*filePoint = fopen(fileName,"r")) == NULL)
   {
      printf("Can't open %s for reading \n",fileName);
      return 0;
   }
   else
   {
      *filePoint = fopen(fileName,"r");
      return 1;
   }
}


/*close file */

void CloseFile(FILE **filePoint)
{
   fclose(*filePoint);
}


/* Print File contents */

void PrintFileContents(FILE **filePoint)
{
   char info[20];

   while ((fscanf(*filePoint,"%s",info)) != EOF)
   {
      printf("%s\n",info);

   }
}


-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

             reply	other threads:[~1997-10-26 12:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-10-26 12:46 Steven I. Pollmann [this message]
1997-10-26 20:18 ` $Bill Luebkert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199710262046.PAA17818@romeo.its.uwo.ca \
    --to=spollman@julian.uwo.ca \
    --cc=gnu-win32@cygnus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).