|
From: blalock <wi...@ea...> - 2000-11-15 19:36:55
|
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
|
|
From: <com...@ya...> - 2002-11-02 11:14:31
|
hi all:) i'm new to this group and i'd like to ask you all a question : me and my friend are working on a project,we'd like to have the results in another file but none of us knows how to do that... anyone who can help?? --------------------------------- Gesendet von http://mail.yahoo.de. Möchten Sie mit einem Gruß antworten? http://grusskarten.yahoo.de. |
|
From: Zodiaq <zo...@ac...> - 2002-11-02 13:35:29
|
Hello j and all Dev-C++ users, Saturday, November 2, 2002, 12:14:31 PM, j wrote as follows: jb> hi all:) jb> i'm new to this group and i'd like to ask you all a question : me and my friend are working on a project,we'd like to have the results in another file but none of us knows how to do that... jb> anyone who can help?? First: don't use html when sending here question or answers... Second: another file you say?? This is totally not possible! Or very very hard - you would have to write special low level driver in ASM, then intall it into your OS to finally write biiiig GUI ( ind Visual Basic) for it - then you'd have debug it for more than a year... you waould have to add some useless feature - and after all this wark you'll get it... a new OS able to write files... yeeeeeeeeha! -- regards, Zodiaq |
|
From: <jp...@bo...> - 2002-11-02 14:53:19
|
Maybe they're just asking how to handle files in C/C++... If this is the case I sugest you to look for it in any book. Most of them has a part dedicated to this subject. ---------------------------------------------- Juliano P=E1vel Brasil Cust=F3dio http://www.jpavel.rg3.net --------------------------------------------- -----Original Message----- From: dev...@li... [mailto:dev...@li...] On Behalf Of Zodiaq Sent: s=E1bado, 2 de novembro de 2002 10:36 To: Dev...@li... Subject: Re: [Dev-C++] newbie question Hello j and all Dev-C++ users, Saturday, November 2, 2002, 12:14:31 PM, j wrote as follows: jb> hi all:) jb> i'm new to this group and i'd like to ask you all a question : me=20 jb> and my friend are working on a project,we'd like to have the results jb> in another file but none of us knows how to do that... anyone who=20 jb> can help?? First: don't use html when sending here question or answers... Second: another file you say?? This is totally not possible! Or very very hard - you would have to write special low level driver in ASM, then intall it into your OS to finally write biiiig GUI ( ind Visual Basic) for it - then you'd have debug it for more than a year... you waould have to add some useless feature - and after all this wark you'll get it... a new OS able to write files... yeeeeeeeeha! --=20 regards, Zodiaq ------------------------------------------------------- This sf.net email is sponsored by: See the NEW Palm=20 Tungsten T handheld. Power & Color in a compact size! http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0001en _______________________________________________ Dev-cpp-users mailing list Dev...@li... TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm https://lists.sourceforge.net/lists/listinfo/dev-cpp-users |
|
From: Abhijit S. <mu...@gm...> - 2002-11-02 15:27:30
|
> Maybe they're just asking how to handle files in C/C++... If
> this is the case I sugest you to look for it in any book. Most of them
> has a part dedicated to this subject.
Zodiaq was being sarcastic... he tends to do that sometimes :).
Anyway, J B, look up file I/O in any book. In C++, we use the ifstream and
ofstream classes to manage this. A small example:
#include <fstream>
int main()
{
using std::ofstream;
ofstream of;
of.open("temp.txt");
if(!of)
{
// Error
}
of << "Blah, blah.\n";
of.close();
return 0;
}
___________________________________________________________
Abhijit Shylanath
E-mail: mu...@gm... || ibr...@bi...
Web-site: http://mudeth.tripod.com/
|
|
From: Carlos d. M. <cg...@wo...> - 2002-11-02 17:31:24
|
And for those cases you can use redirection, which means the output to st=
din
is sent to a file you specify, this is for console files. I proved it wit=
h
gprof, which is a part of the compiler's distribution, I haven't ever do =
it
whit my programs, but being this what it is said to be, it shall work.
For that you open the command.exe, or cmd.exe, and type
program yakyakyak > fileyouwantoutput
Abhijit Shylanath escribi=F3:
> > Maybe they're just asking how to handle files in C/C++... If
> > this is the case I sugest you to look for it in any book. Most of the=
m
> > has a part dedicated to this subject.
>
> Zodiaq was being sarcastic... he tends to do that sometimes :).
>
> Anyway, J B, look up file I/O in any book. In C++, we use the ifstream =
and
> ofstream classes to manage this. A small example:
>
> #include <fstream>
>
> int main()
> {
> using std::ofstream;
>
> ofstream of;
>
> of.open("temp.txt");
> if(!of)
> {
> // Error
> }
>
> of << "Blah, blah.\n";
> of.close();
>
> return 0;
> }
>
> ___________________________________________________________
>
> Abhijit Shylanath
>
> E-mail: mu...@gm... || ibr...@bi...
> Web-site: http://mudeth.tripod.com/
>
> -------------------------------------------------------
> This sf.net email is sponsored by: See the NEW Palm
> Tungsten T handheld. Power & Color in a compact size!
> http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0001en
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|
|
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
>
|
|
From: Ioannis V. <no...@ya...> - 2000-11-17 14:21:57
|
If you want to read in ASCII format use fgets(). If you want to read in raw data use fread(). > -----Original Message----- > From: dev...@li... > [mailto:dev...@li...]On Behalf Of blalock > Sent: Wednesday, November 15, 2000 9:37 PM > To: dev...@li... > 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 > __________________________________________________ Do You Yahoo!? Talk to your friends online with Yahoo! Messenger. http://im.yahoo.com |