I have program where i have to check to see if file exist, if it does not then it needs to be created. SO I have a read file that works fine, if th efile exist it reads whats in it, if it does it says the file does not exist. Now Im trying to creata function that creates the file if it doesnt exist. so in my read function when the person enters the name of the file to be checked for..I pass that name to a variable called name..Hoping that I could then pass it into my create file function if it does not exist..and use that variable to pass the name they entered into the createfile array..called filename.. but I am having trouble because i get error when i try to pass from a string name to char array.. even when I change the varialbe name to char, or char [256] it will not work.. I try to fing a way to convert th string to a char using the strncopy function but still no dice..here the code i have for the createfile funciton
Ok I tried that but its still didnt work..maybe something is wrong with my main function.
Here is the all the code..Please ignore the extra variable, I plan to add more to the code using those variables.
that kinda defeats the purpose..I dont want ot ask twice.. the project requires me to write a program that ask for the name of the file, if the file does not exist then it creats the file.. If I add the cod eyou just wrote, I will be asking the for the name of the file twice.. I can only ask once..
if I could ask for it one time around line 37 and 38..and then pass it to a variable ..."name"... and then use that in both funcitons to pass to the filename array.. that would be great..either way i can only ask for the file name once..and then check to see if it exist if it does not..then i have to create the file..
I tried to use a pointer, but it still doesnt work...Can somebody please help me with this.. I triend all kinds of way to make this work, and looked all over cplusplus tutorial, and google other sites..I can't figure this out