Похожие чаты

Can someone explain why I got: "Segmentation fault" this time? I've

no idea how to search for a solution to this issue.

14 ответов

28 просмотров

Which language is this ?

You're initializing a char* using a const char* which is wrong by itself because it may cause the error you're going to get like that one.

In short, char* cannot be changed. It's a const.

Extending what Sahand said, in C char* ptr = <string-literal>; This gives you a pointer to a string literal which is not modifiable (it is in the text segment in asm generated which is read only). If you wish to modify the string use the literal to initialize an array char str[] = <string-literal>; Unlike the above case it'll create the array on stack using the literal. Which should allow you to modify the array

Emmanuel_230001007
Which language is this ?

It's C, which shouldn't be surprising considering we are in a C/C++ group.

Ali-Ayed / FREE PALESTINE 🇵🇸 Автор вопроса
Emmanuel_230001007
Which language is this ?

Sorry for being late. Anyways, It's C; I think you can tell from the void function parameter.

Ali-Ayed / FREE PALESTINE 🇵🇸 Автор вопроса
Sahand 🏔️
In short, char* cannot be changed. It's a const.

Really? But, let's be real, It's really confusing why const char *str can be changed.

Ali-Ayed / FREE PALESTINE 🇵🇸 Автор вопроса
Manav | avoid unnecessary messaging me
Extending what Sahand said, in C char* ptr = <str...

Yeah, but why I can modify it although it's const char* as shown in the previous message.

Ali Ayed / FREE PALESTINE 🇵🇸
screenshot Really? But, let's be real, It's really confusing ...

You're assigning to a pointer to const data. The pointer itself is not const there. For example *message = is not possible.

Ali-Ayed / FREE PALESTINE 🇵🇸 Автор вопроса
Azadi
You're assigning to a pointer to const data. The p...

Oh yeah. Now I figured it out. Thank y'all for helping.

Ali Ayed / FREE PALESTINE 🇵🇸
screenshot Really? But, let's be real, It's really confusing ...

It is fully legal make a const ptr , point to another address. You just can't change the value of the content that it points to.

Ali-Ayed / FREE PALESTINE 🇵🇸 Автор вопроса
Sahand 🏔️
It is fully legal make a const ptr , point to anot...

Yup, you're right. I get a segmentation fault when I tried to change a single character.

Sahand 🏔️
In short, char* cannot be changed. It's a const.

char* just like any other regular pointer can be changed.

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта