Give Path Of File In Dev C++ To Read

Posted on  by
Give Path Of File In Dev C++ To Read Average ratng: 8,8/10 7145 reviews
I need to let the user input a file name/location ex: c:/school/cs-121/labData.txt
the lab data is formatted like this
149.99 3250
99.99 15587
49.99 18564
39.99 23450
I need to take that information and figure out total tickets sold and total money made but that part is easy. I just need to get the data file in the some how and separate the data into variables I can use. I got the declarations like this..
double boxPrice;
double box;
double sidelinePrice;
double sideline;
double premiumPrice;
double premium;
double generalPrice;
double general;
I need to fill them in like this
double boxPrice = 149.99 ;
double box = 3250;
double sidelinePrice = 99.99;
double sideline = 15587;
double premiumPrice = 49.99;
double premium = 18564;
double generalPrice = 39.99;
double general = 23450;
but using the input file data. I have been searching for hours and our text book doesn't have any good examples of how to do this. Please don't write the entire thing for me, just how to accept the input from the user and assign a value using the file and any necessary declarations or include statements.
  1. Give Path Of File In Dev C++ To Reading
  2. Give Path Of File In Dev C++ To Read Free

Hi all,

Path

The if statement works fine and so does the last part for writing the file. However, I've tested it out without adding the 'C: ' to the file names and it worked fine, but when I try and set the location to read the input file, it doesn't work, it ends up writing 'test1.txt' as a blank file, presumably because it could not read the input file. Jul 22, 2009  This is a public user forum not an official Dev-C support service. As such you need to; a) think about what you are saying, b) listen to what others are saying, c) abide by the conventions of the forum, d) be somewhat robust to criticism - not everyone is going to be nice to you or suffer fools gladly. Any support you get is a cooperative process, to be effective you.

Using my application I've found a file path anywhere on my machine and store the full path in a CString variable. That is full path, like this,

What I want to do is, find the name of the file(without the extension), 001_002_003 according to my example. Then separate as 001 002 and 003, then write them to a file in three columns.

I'm stuck with how to get that three part, 001 002 and 003, from the full file path.

Give Path Of File In Dev C++ To Reading

Thanks.

  • 7 Contributors
  • forum 14 Replies
  • 1,349 Views
  • 5 Years Discussion Span
  • commentLatest Postby GorfLatest Post

Salem5,138

3utools.dmg for mac. DOS used to have a 'splitpath' function which returned the various components of a full path.

Give Path Of File In Dev C++ To Read Free

Or you could do
- find the last to mark the start of the filename
- find the last . to mark the end of the filename.