Anonymous
Just returning is not
Serenity
Why's that ?
Anonymous
Try googling
Sasuke
I copied a character array to dynamic array
Sasuke
Character by character like
DynamicArary[x][y] = fixedArray[z]
Sasuke
However I haven't copied '\0' character
Sasuke
But I can easily iterate through dynamic array with index
Sasuke
Why? I expect error here because how does C know where to stop?
Alex
show code how do you iterate. and how you declare array
Sasuke
Sasuke
Iteration is on line 32 rest copying and allocation are commented
Alex
for (int i = 0; i < numberOfStrings; i++) {
printf("%s\n", command[i]);
}
you just traverse command[0], command[1] etc until i < numberOfStrings. you don`t need \0 for this
Sasuke
but why C finds out when first element end by \o character
Sasuke
since strings are just character sticked together
Sasuke
Alex
what do you mean C? what function do you use?
Alex
In C you can use \0(standard approach) or can use just variable for string length
Alex
in the second case stdlib is not for you
Sasuke
Alex
if you have string usually you have to add \0 to the end of string
Alex
if you have array you don`t have to add \0
Sasuke
Alex
it is UB in this case. no guarantee it will work on other hardware in the future
Alex
printf("%s\n", command[i]);
Sasuke
Alex
for printf(%s function call command[i] must be ended with \0, so you should
Alex
and you should allocate +1 byte for each string for \0 byte
Sasuke
Sasuke
I added \0 in the end
Sasuke
Now
Sasuke
Thankyou
Alex
welcome
Manuel
Done
Dima
/ban @meak666
Hermann
where can I find good programming rules about C? I mean how to formally write the code, avoid using the variables incorrectly: such as understanding how to manage global variables and when to use them etc ...
Anonymous
Hermann
sorry me, i talk about C
PO
I need help
PO
I get segmentation fault (core dumped), while I write my whole function into new_file.c
Hermann
PO
Hermann
I don't get along with the French
Hermann
PO
https://paste.ubuntu.com/p/rTWkTsxsQJ/
PO
g_signal_connect(G_OBJECT(charge_image_bouton), "clicked", G_CALLBACK(check), (addition *) p );
Anonymous
sorry me, i talk about C
There's good book called Modern C
AFAIK it's free for every one
But my advice is to stop writing C, it's not a language for good code
Anonymous
Anonymous
F
klimi
Anonymous
Indolent
What exactly does "string("")" keyword does in: "accumulate(sample.begin(), sample.end(), string(""))";
Indolent
Where sample is: vector<string> sample;
Indolent
So it turns out that it adds a string "" at the beginning of the sample vector.
Cengizhan
Concatenate strings without any characters. If last parameter was string(“ “), my example would be “Hello world”
Indolent
Can you do some alteration with the first two parameters namely: sample.begin(), sample.end() ?
Indolent
Like what if instead at the beginning I want to add in the middle of the string?
Đỗ
no, it's only a cookbook
Indolent
i = i == 1 ? 0 : 1;
Indolent
What is the meaning of the above line?
Cengizhan
Indolent
Then why i = at the beginning?
Indolent
Why not just i == 1 ? 0 : 1
Indolent
oh fuck
Cengizhan
Thats why we keep equal sign first there.
Indolent
omg why didn't i thought of that
Indolent
we're simply assigning the value of i
Indolent
No Kardarshians here
Cengizhan