ok i just need to know how i can make the file save in the directort i want it to, and how to be able to pass a variable into the name of the file ill show you the program im making and you'll see
Code:#include <fstream> #include <iostream> using namespace std; int main() { char PlayerFirstName[50]; char PlayerLastName[50]; char PlayerFullName[100]; char CharacterName[50]; char Class[50]; char Race[50]; int hp; int xp; int Mana; int stop; std::cout<<"Enter Player First Name: "; std::cin>>PlayerFirstName; std::cout<<"Enter Player Last Name: "; std::cin>>PlayerLastName; strcat ( PlayerFullName, PlayerFirstName ); strcat ( PlayerFullName, " " ); strcat ( PlayerFullName, PlayerLastName ); std::cout<<"\nEnter Character Name: "; std::cin>>CharacterName; std::cout<<"\nEnter Class: "; std::cin>>Class; std::cout<<"\nEnter Race: "; std::cin>>Race; std::cout<<"\nHow many Hitpoints?: "; std::cin>>hp; std::cout<<"\nHow much Experience?: "; std::cin>>xp; std::cout<<"\nyour player is.... \n \n \n\n\n\n\n"; std::cout<<"Player Name: "<<PlayerFullName<<"\nCharacter Name: "<<CharacterName<<"\nclass: "<<Class<<"\nRace: "<<Race<<"\nHitpoints: "<<hp<<"\nExperience: "<<xp; ofstream Playerfile ( "player.txt" ); Playerfile<<"Player Name: "<<PlayerFullName<<"\nCharacter Name: "<<CharacterName<<"\nclass: "<<Class<<"\nRace: "<<Race<<"\nHitpoints: "<<hp<<"\nExperience: "<<xp; std::cin>>stop; }
what i want is what is passed to variable PlayerFullName to be what is the file name (instead of just player.txt) because i want to be able to creat a lot of these without erasing any also i want to be able to easily find my files i saved any help would be appreciated



LinkBack URL
About LinkBacks


