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
how can one put two functions in one program?
Just like you put the first one, second function goes the same way
Anonymous
Or you mean two functions with same name?
Morgan
Or you mean two functions with same name?
Send me like the body or format of how it can be put
Anonymous
function1() { . . . } function2() { . . . }
Anonymous
Void
It's upto him xD
Morgan
Void
Art it as in ? I'm A beginner use simplified terms please
Anonymous
Y
Y not
klimi
Y not
Yes not?
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
Y - yes
Ok sir
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
😂😂😂
klimi
I don't 😜
You say no more often
klimi
I got it
Anonymous
😂😂
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;
Daniele°
./bin/start.c: In function ‘gettime’: ./bin/start.c:15:10: warning: function returns address of local variable [-Wreturn-local-addr] return buffer;
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); } ... char t[256]; gettime(t);
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°
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
Daniele°
how to free variable t if i'm using this example?
No, you need a free only if you use a malloc
veficos
free() is used when malloc() is used to allocate memory
Volad Malevich
just do gettime(t)? will be t rewritten after next usage gettime(t)?
veficos
char t[256]; gettime(t);
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
😊