Good afternoon so my dilemma is i want Qt to create a new .txt file every time the save button is pressed and later on send data to ui->…..as of now i was able to do it in c++:
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
int main ()
{
int n=1,i=1;
std::string name, grade, gpa;
while(n==1)
{
std::cout << "Enter student info : " << std::endl;
std::cout << "Name : ";
std::cin >> name;
std::cout << "Enter grade level : ";
std::cin >> grade;
std::cout << "Enter GPA : ";
std::cin >> gpa;
std::ofstream file("Student" + std::to_string(i) + ".txt");
file << name << std::endl
<< grade << std::endl
<< gpa << std::endl;
cout<<" continue?"<<endl;
cin>>n;
i++;
}
}
but in Qt iIm having issues id be super grate full if anyone can please help
enter image description here
I tried moving the c++ code over and got errors and i tried “c:// ……”+[n+1}”.txt”)
New contributor
Ruben P is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.