klimi
You don't initialize temp?
klimi
Oh you doo
klimi
Polish is nice language
Box of
well, it's a bit hard :p
Mat
Doesn't strcp(str1, str2, n) copy str1 in str2?
Box of
yes, but strncpy gives you control of how many characters you want to copy
Box of
and I was supposed to make my version of strncpy
Box of
actually it's str2 to str1
Mat
Okay
Mat
Why do you return temp?
Box of
function is supposed to return str1
Mat
Oh okay
Mat
Right
olli
Yes it is dangerous, never return a pointer to a local element! Using variable length arrays is not required to be supported (c compliance) Btw this is only strncpy works
Box of
as far as I know VLA is optional since C11 and this was only way I could think of to get it done
Box of
Do you have any other idea how to get it properly done?
olli
Why do you need the temporary array at all?
Box of
What do you mean? I need to return str1
olli
Yes, but what's the purpose of temp?
Box of
function should write str2 to str1 and return str1
Box of
it holds copy of str1
Box of
str1 without str2
olli
But you don't use it and you lose it after the function returns anyway?
Box of
I use it to return initial str1
olli
So the return temp is there on purpose?
Box of
yes
olli
This might trigger undefined behavior
Box of
in main you have temp=strnkop(str1,str2,n);
Box of
This might trigger undefined behavior
is there any way to trigger it on purpose?
Box of
I'd like to see what can happen
olli
is there any way to trigger it on purpose?
depends on your compiler and settings when i enter hallo and hello and output str, str2 and temp the result will be hallo hallo ╚²e
Box of
with clang it works fine, with gcc i get (null) on temp
Box of
interesting
Box of
so, I checked everything again from the very begining and not only I made my version of strncat instead of strncpy but I also understood incorrectly how it works. strncpy copies str2 to str1 and returns modifed str1
Box of
but hey, I learnt something new
Box of
here's nice fully compliant function:
Box of
char *strnkop(char *s1, const char *s2, int n) { int i,j; i=strlen(s1); for(j = 0;j<n;j++) s1[j]=s2[j]; s1[i]='\0'; return s1; }
klimi
yo humans
Mihail
yo humans
Sup superhuman boi?
klimi
im super
BinaryByter
yo humans
why don't you greet me?
klimi
yo maxi
BinaryByter
Thanks ❤️
Anonymous
Why is brilliant?
Anonymous
۸
Anonymous
Cool
Boet
@linuxer4fun @Kurimi
BinaryByter
/warn can you please gift them to me?
Anonymous
Y u warn.. u want udemy??
BinaryByter
Anonymous
😂
BinaryByter
😂
You find that funny?
Anonymous
He tried to do it too 😁😁😁
BinaryByter
I can try it on you
BinaryByter
XDD
Anonymous
Try remove warning instead?
BinaryByter
Works
Anonymous
❤️
BinaryByter
Allah forbids being gay
Anonymous
Brother all love yes
Anonymous
Not gay
Roxifλsz 🇱🇹
Anonymous
Add me in ot plzz
Anonymous
I will not abuse
Anonymous
Unban 😁😁😁
Thespartann
Um
Thespartann
Lol
Anonymous
Y u lol
Thespartann
Tel us
Thespartann
Mihail
Lmao
Mihail
Why?
Thespartann
Google it for us
Thespartann
Tho i only use ddg.gg
Thespartann
Sorry :(
klimi
i hate libusb!
klimi
idk how the linux works
klimi
i hate it
klimi
Lol
really