|
-
Nov 25th, 2001, 02:45 PM
#1
Thread Starter
Fanatic Member
Combine 2 strings
Time passed by merrily as we celebrate Thanksgiving, Christmas is about to come and have you ever prepared for the happiness that you will have?
Code:
#include <iostream>
#include <time.h>
#include <stdio.h>
using namespace std;
int main(){
time_t T;
FILE *t;
time(&T);
char PATH[256]="c:/" + ctime(&T) + ".txt";
t=fopen(PATH,"r");
fclose(PATH);
return 0;
}
I want the PATH to be c:/TIME FOR NOW.txt, but the problem is it turns an error, can anyone help me out?

prog_tom
JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
http://physics.sviesoft.com/forum
-
Nov 25th, 2001, 02:48 PM
#2
Good Ol' Platypus
Aren't defaults for variables like constants that you can't use functions and such?
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Nov 25th, 2001, 03:00 PM
#3
Thread Starter
Fanatic Member
I don't know
I'm not as advance as you think, please be amplified.

prog_tom
JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
http://physics.sviesoft.com/forum
-
Nov 25th, 2001, 03:13 PM
#4
You need to use strcpy and strcat. Does anybody EVER read the FAQ???
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Nov 25th, 2001, 03:14 PM
#5
Thread Starter
Fanatic Member
Code

prog_tom
JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
http://physics.sviesoft.com/forum
-
Nov 25th, 2001, 03:19 PM
#6
Code:
#include <iostream>
#include <time.h>
#include <stdio.h>
using namespace std;
int main()
{
FILE *t;
char PATH[256];
strcpy(PATH, "c:/");
strcat(PATH, ctime(time()));
strcat(PATH, ".txt");
t=fopen(PATH,"r"); // this could cause problems: "rt" would be preferred
fclose(t); // change here
return 0;
}
ctime takes time_t as argument, not time_t*.
probably logical error: you're opening a file for reading that will most likely not exist.
Last edited by CornedBee; Nov 25th, 2001 at 03:24 PM.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Nov 25th, 2001, 03:22 PM
#7
Thread Starter
Fanatic Member
Problem?
What type of problem will it might cause. What does rt mean? What does it do?

prog_tom
JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
http://physics.sviesoft.com/forum
-
Nov 25th, 2001, 03:34 PM
#8
b opens the file for binary mode - if you want to save numbers and such. t opens it for text mode. If you don't specify one of those, the content of the global variable _fmode is used, so you can either set a variable that may affect ALL files, or you simply have to put up with the mode fortune chooses for you.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|