#include "pch.h"
#include <iostream>
#include <fstream>
#include <string>
using std::cout;
using std::ifstream;
using std::string;
int main()
{
std::cout << "Hello World!\n";
int winwidth, winheight, wincolor; // Declare your variables
winwidth = winheight = wincolor = 99; // Set them all to 0
string path = "TextFile1.txt"; // Storing your filename in a string
ifstream fin;
fin.open(path); // Open the file
if (fin.is_open()) // If it opened successfully
{
fin >> winwidth >> winheight >> wincolor; // Read the values and
// store them in these variables
fin.close(); // Close the file
}
else
{
std::cout << " file not opened successfully..." <<std::endl;
}
cout << winwidth << '\n';
cout << winheight << '\n';
cout << wincolor << '\n';
return 0;
}
The easiest way to find out where the input file must be is to first create an output file, then place your input file in the directory that contains that output file.
#include "pch.h"
#include <iostream>
#include <fstream>
#include <string>
using std::cout;
using std::ifstream;
using std::string;
int main()
{
std::cout << "Hello World!\n";
int winwidth, winheight, wincolor; // Declare your variables
winwidth = winheight = wincolor = 99; // Set them all to 0
string path = "C:\\Users\\clang\\source\\repos\\fileops5\\TextFile1.txt"; // Storing your filename in a string
ifstream fin;
fin.open(path); // Open the file
if (fin.is_open()) // If it opened successfully
{
fin >> winwidth >> winheight >> wincolor; // Read the values and
// store them in these variables
fin.close(); // Close the file
}
else
{
std::cout << " file not opened successfully..." <<std::endl;
}
cout << winwidth << '\n';
cout << winheight << '\n';
cout << wincolor << '\n';
return 0;
}
If you are looking for the place to drop the file so you can just use string path = "TextFile1.txt";...
probably something like...
In Visual studio, once the solution is built for the first time.
Go to the Solution Explorer and right click on the 'Solution' node at the top and in the context menu, go down to 'Open Folder in File Explorer' and click.
In the explorer view look for a folder called 'Debug' or 'Release' depending on your build settings. Drop the test file in that folder.
It looks like the default working directory is set to the project directory, so unless you change it the it should be fine in the source directory.
I missed Thomas1965 earlier post about the working directory but it looks like they have moved it...in the project properties it is under configuration properties->Debugging->working directory
In Visual studio, when the arrangement is worked out of the blue.
Go to the Solution Explorer and right tap on the 'Arrangement' hub at the best and in the setting menu, go down to 'Open Folder in File Explorer' and snap.
In the traveler see search for an organizer called 'Investigate' or 'Discharge' contingent upon your assemble settings. Drop the test record in that organizer.
___________________________________________________________
https://plex.software/ , https://luckypatcher.pro/ ,https://kodi.software/