How do I write a program that takes in some data files that have a bunch of numbers in them and then spits out certain numbers. Which then would be decoded using ascii values.

You dont have to write the program, but it would really help full if you could explain me how. I want to learn it not cheat.

I tried as hard as I could, but loops and ifstream, are something I cannot understand. Please help. Bye the way the program must use ifstream and loops.

Recommended Answers

All 6 Replies

Here u are.

> The Design Assignment is due by Friday at 6:00 p.m.,
Better get to it then.

>I tried as hard as I could, but loops and ifstream, are something I cannot understand.
Mmm, so post what you managed to do so far then.

> The Design Assignment is due by Friday at 6:00 p.m.,
Better get to it then.

>I tried as hard as I could, but loops and ifstream, are something I cannot understand.
Mmm, so post what you managed to do so far then.

Except for the organization and commentsh.... i did not do shit.. I am just so confused with this assignment... I think I did enough for the design assignment but.. I want to know learn how to actually do it and understand it...

> I am just so confused with this assignment
But you waited until 12 hours to go before seeking help?
Help we're happy to give, but throwing you "hail mary" passes with minutes to spare isn't going to happen.

So how did you manage your previous assignment then?
Most assignments build on previous knowledge, and add a new thing (ifstream I would guess).
I'm pretty sure you must have done loops by now.

For the ifstream thing, then

int myInt;
cin >> myInt;

should be no stranger to you.

It is but a very small step to

ifstream myStream;
int myInt;
myStream >> myInt;

Unless you've been cheating your way though so far, in which case you're already hopelessly out of your depth, and falling at an ever increasing rate.
If this is you, just drop the course now and be done with it.

> I am just so confused with this assignment
But you waited until 12 hours to go before seeking help?
Help we're happy to give, but throwing you "hail mary" passes with minutes to spare isn't going to happen.

So how did you manage your previous assignment then?
Most assignments build on previous knowledge, and add a new thing (ifstream I would guess).
I'm pretty sure you must have done loops by now.

For the ifstream thing, then

int myInt;
cin >> myInt;

should be no stranger to you.

It is but a very small step to

ifstream myStream;
int myInt;
myStream >> myInt;

Unless you've been cheating your way though so far, in which case you're already hopelessly out of your depth, and falling at an ever increasing rate.
If this is you, just drop the course now and be done with it.

This is the first time I am using a fstream and loops. I assure you I never got any information before. I dont want code now either. I just want to know How to do it and understand how it is done. I will write code myself.

fstreams are something I dont understand at all. Supposidley they are easy.. but they are not for me. loops I can do them myself.

And the last minute submission... Told ya.. I don't have to worry about the design assignment... it is the next lab.. which is due next wednesday that I am actually worried about. I already am done with the design assignment.

fstream is how you read information to and from files and the syntax is messy but you will find their usage in lots of places

to read in from a file

#include <fstream> //needed for if stream class
#include <string>

int main()
{
//std is a namespace saying where ifstream can be found
std::string filename("C:\\some_file.txt");
//need to give file name as char * not std::string
std::ifstream fin(filename.c_str(), std::ios::in); //this opens an ascii file direclty
if(fin.is_open() == true)
{
/*
you can now use a memory buffer
char *buf = new char[max_bytes_to_read];
might use some of  the following methods
.read(); 
seekg();
.gcount();
getline();
*/
fin.close()
}
else
{
//could not open file
}
return 0;
}

This is not complete code but if you google read write c++ of fstream
you can find reference to the methods in fstream and examples

there are friendlier methods such as SALEM mentioned
but don't forget the std::

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.