Hey, I'm rather new at C++ (just started today, actually.) And as practice I'm trying to write a program to create a stat block for DnD and output it to notepad.
This is my problem:
I'm trying to create multiple variables using a loop, for example, prof1, prof2 and so on. This is what I have, and it doesn't work:
Code:
#include <fstream>
#include <iostream>
using namespace std;
Code:
int numclass;
int numloop = 0;
Code:
cout<<"Number of classes: ";
cin>> numclass;
while ( numclass < x ) {
char prof>>x[50]; This is what I tried... didn't work.
cout<<"Class Name: ";
cin.getline ( prof>>x, 50, '\n' );
cout<<"Level: ";
cin>> level;
x++;
}
I also want to be able to reference to it again using a loop, how would I do that?
Next problem: I want to be able to output the file as a .txt file, so I use this:
Code:
ofstream out (name".txt");
Again, that didn't work for me. I want to be able to name it as whatever name the person gave it and then .txt.
Any help would be greatly appreciated. Thanks!