Tushar
Case
Tushar
桃桃乌龙
I thought buffers and pointers are not exact the same thing in C, but in machine language it really is, they’re just offsets
Tushar
Try this
Tushar
Correcting
Tushar
It
klimi
Wtf is e1.e2.dob2[]
klimi
You need to put index in that
klimi
[] is invalid syntqx
Tushar
klimi
Where do you define e1?
klimi
You need to have in main something like name e1;
DaVlad 🇸🇰
simple syntax using char
char *str = "Your string";
klimi
I don't know much I can't do C at all and I am not programmer
DaVlad 🇸🇰
char str[] = "Your string";
Jussi
how about actually using strcpy instead of trying to change the pointer itself?
Tushar
You need to have in main something like name e1;
Are u really trying on compiler or not
Jussi
Now you are trying to assign the POINTER different value, and not copying the string. You cannot copy strings with = in C
Tushar
This is correct.. the mistake is the line 9 only
Jussi
You should really learn the basics
桃桃乌龙
there’s no built-in string type in C while other languages like Java and Python do, char* is literally a pointer to char
Tushar
You should really learn the basics
Please teach me then...
Jussi
if you pay me $40 per hour I will do it
桃桃乌龙
So something like str1 = str2 is just making str1 points to str2
Jussi
It's not a joke though lol
Jussi
and if str2 gets freed, trying to print str1 will segfault
桃桃乌龙
You’re not changing the actualy string content, it’s still there, where str1 was pointing at
Jussi
that is also correct
Tushar
Tushar
Dima
/warn read the rules please
Tushar
/warn
Tushar
Rules plz
Jussi
#rules
DaVlad 🇸🇰
[] is invalid syntqx
It's valid syntax for initialization of array
Tushar
/warn read the rules please
What I did wrong... miss
Jussi
What I did wrong... miss
maybe this? "* Long code snippets must be posted via a snippet website(links below), posting pictures of code and posting long snippets in the group is not allowed."
Tushar
Ohk... sorry for my mistake...
桃桃乌龙
Jussi
That is, however, not always true
well this is rather dangerous :D
桃桃乌龙
The content isn’t erased by calling free() though
桃桃乌龙
Jussi
mmmh
Jussi
and you can find errors like that by using valgrind/memory sanitizer
Nikolas
That is, however, not always true
you are entering the realm of undefined behaviour
桃桃乌龙
yeah it’s called use-after-free
桃桃乌龙
might be a security flaw irl
桃桃乌龙
C is dangerous if you don’t know what you’re doing
Anonymous
What is github
Anonymous
Hello anyone tell me
桃桃乌龙
Hello anyone tell me
http://lmgtfy.com/?q=github
Anonymous
桃桃乌龙
How it works
http://lmgtfy.com/?iie=1&q=how%20github%20works
Anonymous
I'm asking,how can i control my software version using this web based hosting services
桃桃乌龙
you control your software version by using git, it’s not neccessary to use github. basically github hosts git repo for you, but you could do without that. search for tutorials on git.
H̲i̲L̲e̲v̲e̲l̲
Oh there is russian with brain
Anonymous
桃桃乌龙
Are you joking or just trying to be offensive
DaVlad 🇸🇰
well this is rather dangerous :D
It's called unpredictable behaviour
Francisco
It's called unpredictable behaviour
Also known as undefined behaviour
Dima
Lol.
Anonymous
Google searching techniques
Dima
Where these people come out from 😂
桃桃乌龙
I don’t know why ppl say it’s unpredictable… it is actually predictable, it’s not ramdom, with a debugger you could really predict that though no one would waste their time on it.
Anonymous
http://bfy.tw/NzQa
DaVlad 🇸🇰
I don’t know why ppl say it’s unpredictable… it is actually predictable, it’s not ramdom, with a debugger you could really predict that though no one would waste their time on it.
It's about language standard, it means that the standard doesn't say what will happen in that case and it depends on implementation and other things, but it's bad anyway
桃桃乌龙
yeah just don’t do it anyway
Jussi
Some OS kernels might actually null the freed memory
Jussi
So it is UB
H̲i̲L̲e̲v̲e̲l̲
H̲i̲L̲e̲v̲e̲l̲
It's not often
Nikolas
that's quite racist 🤔
Anonymous
It's not often
What's the problem with Russian people?