prog_tom
Nov 25th, 2001, 05:41 PM
#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;
}
I don't know why I cannot convert char to const char. See it for yourself.
#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;
}
I don't know why I cannot convert char to const char. See it for yourself.