I don't know why I cannot convert char to const char. See it for yourself.Code:#include <iostream> #include <fstream> #include <math.h> #include <time.h> using namespace std; #define MAX 256 FILE *f; ofstream VB; char I;int x,k;char p; int main(){ x=time(NULL); srand(x); k=rand()%1000+1; strcpy(p,k); // variable 'k' holds the random number, p holds nothing. char PATH[MAX]; strcpy(PATH,"c:/"); strcat(PATH,p); strcat(PATH,".txt"); VB.open(PATH); VB<<k; VB.close(); cout<<PATH<<endl; cout<<x<<endl; cout<<k<<endl; system("pause"); x=NULL;k=NULL; return 0; }





Reply With Quote