I have a Book1.csv file.
It contains list like this:
bones, origin ,deep or superficial,location,action
frontal,cartiledge,deep,cranial,flexes arms
Now, how can I search a bone, if user enters the action.
Create a class 'bone' with the traits described in the list. Read the file in and create instances of the class 'bone' as elements in a vector of bones. give the class 'bone' a query method that returns true if passed the name of an action it can do.
Once you've done all that you'll able to write an algorithm that gets the name of an action and goes through the vector listing all bones that return true for the query method..
I think my file is not opening because it exits and if I take out the line exit (1), it outputs "Input file opening failed.". Do you know if the program I wrote should open my file?
I can't specifically put in the desktop because I would also have to open in school. So, how can I do it so it would open on any computer which has that file somewhere?
for your filename problem, try creating a string variable 'filename'. Then prompt the user to drag and drop the input file into the command window. Take the file location into the filename variable:
The file does not drag into the command window. Can I tell the user to enter the name of the file? The file will be exactly the same name and content on any computer I need it in. So, isn't there a way for the .csv file to be simply read, instead of having to drag it or asking user for it.
You can do it the way that you first tried, but I've found that while working on the project (I use Visual C++ 2010) if I put the file in the project folder (the one that contains the project source code and header files ) it will open it just fine. When I finish the program, I just put the input file in the same folder as the copied .exe release version of my program and it reads from it just fine.
so use inStream.open("Book1.csv");
but make sure that Book1.csv is in the folder with your source code instead of the desktop and see if that works.
I'm not sure if it's the same for every situation but that's what works for me so far.
The thing though is that I am not sure where my teacher will have the "Book1.csv" file saved and my program saved on the same folder. I thought reading a .csv would be simple as reading .txt file. Is it not?
Let me see if I understand.
You want to open a file named `Book1.csv'.
You don't have idea where that file is located
You don't want the user to write down the path (¿or do you?)
¿do you pretend to search the entire file system for your file?
Put some restrictions.