I am new to C programming and I am having an issue that I can't seem to figure out. I would greatly appreciate anyone's help!
I am making a very simple program that takes some user input and saves it to a file. This is a console application. Getting the core information from the user and storing it into a file is working correctly. I am creating a folder and saving the file into the folder. This is working correctly as well. The problem is that I need to have the user rename the folder and the file. To get the user input I am using cin. I store the user's input into a variable and then write the user input to the file using:
where outfile is my instance of ofstream.
To rename the file and folder, I used the rename() function. This works as long as I hardcode the values. I know that rename() accepts to params that are typed const char*. When I try to place a variable for the 2nd param to rename(), I get an error of:
invalid conversion of string to const char
How can I use a variable to rename the file and folder that my program creates. I have been searching the internet and reference books and can't seem to find an answer. I tried to cast the type and this didn't work and I know that its not good practice.
Can anyone please help!