BinaryByter
they ostream buffer
BinaryByter
though i'ts prolly not the issue
Riccardo
you mean by using flush?
BinaryByter
oh you didn't flush the output?
BinaryByter
bad idea
Riccardo
ok i forgot about that too
Anonymous
Hi
taru
Hello
klimi
hi
Morgan
how can one put two functions in one program?
Anonymous
Or you mean two functions with same name?
Anonymous
function1() {
.
.
.
}
function2() {
.
.
.
}
klimi
klimi
Morgan
Anonymous
Void
It's upto him xD
Morgan
Void
Art it as in ? I'm A beginner use simplified terms please
klimi
Anonymous
klimi
Anonymous
Oh lmao
klimi
Wtf o.o
klimi
Y - yes, N - no
Anonymous
klimi
No
klimi
Y - yes
Anonymous
:P
Morgan
What do you mean😂😂
Anonymous
klimi
Why - why
klimi
Ok sir
Don't ever call me sir pleaaseee
klimi
I'm allergic to that
klimi
Y = why
How to you say yes with one letter then?
⠠⠍⠥⠓⠁⠍⠍⠁⠙⠽⠥⠎⠥⠋
Morgan
Geeks
Morgan
😂😂😂
Anonymous
Anonymous
klimi
I got it
Anonymous
😂😂
Thespartann
Thespartann
Volad Malevich
hello, help me pls. How to return function value as string after strftime?
Volad Malevich
const char *gettime(){
char buffer[256];
time_t curtime;
struct tm *loctime;
curtime = time (NULL);
loctime = localtime (&curtime);
strftime (buffer, 256, "%d.%m.%Y %H:%m:%S ", loctime);
return buffer;
}
Volad Malevich
I plan to use this one
klimi
ヤ
Ok ^^ but that's 2 letters
veficos
use C++?
klimi
Or you would need 12 key keyboard
Volad Malevich
char time_[500];
time_ = gettime();
Volad Malevich
i'm using C
veficos
char *time_;
time_ gettime();
veficos
char *time_;
time_ = gettime();
Volad Malevich
./bin/start.c: In function ‘gettime’:
./bin/start.c:15:10: warning: function returns address of local variable [-Wreturn-local-addr]
return buffer;
veficos
Because you're using local variables
veficos
BTW, This way cannot be used in multithread
Daniele°
const char *gettime(){
static char buffer[256];
time_t curtime;
struct tm *loctime;
curtime = time (NULL);
loctime = localtime (&curtime);
strftime (buffer, 256, "%d.%m.%Y %H:%m:%S ", loctime);
return buffer;
}
...
char* t = gettime();
veficos
const char *gettime(){
char *buffer = malloc(sizeof(char) * 256);
time_t curtime;
struct tm *loctime;
curtime = time (NULL);
loctime = localtime (&curtime);
strftime (buffer, 256, "%d.%m.%Y %H:%m:%S ", loctime);
return buffer;
}
....
char *t = gettime();
...
free(t);
Volad Malevich
how better to use t if i need to output log with timestamp and t variable will get gettime() every second??
Daniele°
const char *gettime(){
char* buffer=malloc(256);
time_t curtime;
struct tm *loctime;
curtime = time (NULL);
loctime = localtime (&curtime);
strftime (buffer, 256, "%d.%m.%Y %H:%m:%S ", loctime);
return buffer;
}
...
char* t = gettime();
...
free(t);
Volad Malevich
should i free(t) every time after using?
Daniele°
Daniele°
veficos
Volad Malevich
@veficos actually not every second, but every command of bin file. It will be logging to file
Volad Malevich
i get "warning: attempt to free a non-heap object ‘t’ [-Wfree-nonheap-object]
free(t);"
Volad Malevich
wait pls
Volad Malevich
Daniele°
veficos
free() is used when malloc() is used to allocate memory
Daniele°
Volad Malevich
just do gettime(t)? will be t rewritten after next usage gettime(t)?
veficos
char t[256];
gettime(t);
veficos
Volad Malevich
is there way to get microseconds using this way?
void gettime(char* buffer){
time_t curtime;
struct tm *loctime;
curtime = time (NULL);
loctime = localtime (&curtime);
strftime (buffer, 256, "%d.%m.%Y %H:%m:%S ", loctime);
}
veficos
yep
Volad Malevich
😊