|
From: lstar36 <ls...@fl...> - 2000-11-16 00:04:26
|
This small program will read your file with all char included.
Once you get further into "c" you will learn about structures & objects,
which are much better for file applications.
lstar36
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
void main(void)
{
FILE *stream;
char string[132];// be sure to make this array as big as your
longest string
char *eof;
int size;
size = sizeof(string)+1;
eof = malloc(size); // allocate memory for string
stream = fopen("Myfile.txt","r");
do
{
// returns a NULL on end of file
eof = fgets(string, size, stream); //reads a max of 132 char or
untill new line.
printf("%s", string); //
}while(eof != NULL);
}
----- Original Message -----
From: "blalock" <wi...@ea...>
To: <dev...@li...>
Sent: Wednesday, November 15, 2000 1:36 PM
Subject: [Dev-C++] newbie question
> Can I format input from a file inside of the file or do I have to do
> this through code? I am trying to import characters into my program as
> they are in the file. when I use fscanf it ignores the spaces. I was
> wondering if there is a way to essentially cut and paste from a file to
> my program including the spaces and returns. To explain, I am trying to
> import ascii art into the introduction portion of my program, so the
> input file needs to be formatted exactly as it is spaces and all. I am
> taking a class in C, very new at this, so I am playing with it.....
> thanks in advance for the reply.
> Blalock
>
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> http://lists.sourceforge.net/mailman/listinfo/dev-cpp-users
>
|