Danya🔥
Danya🔥
Pol
I wish I could find something more elegant, but I guess I will need more time for that.
Danya🔥
Pol
I think I have to build the local item to concat and allocate the array inside the for loop.
Pol
So I will need a bit more time to do.
Anonymous
Initialization
Anonymous
OK,i know
Danya🔥
Pol
Because I can only use C right now. C++ is not in the scope.
Danya🔥
Anonymous
ok
Pol
yes, I'm learning it at Uni.
Anonymous
pure C makes people crazy
Pol
I had the crazy idea to go back to school... 20 years later :)
Anonymous
That's why every language has its own expertise
Danya🔥
Pol
Found a nice solution !
Pol
char* item = NULL;
size_t item_length = 0;
for (int i = 0; i < size; i++) {
item_length = snprintf(NULL, 0, "%i", arr[i]);
if (i < size - 1) {
item_length += strlen(separator);
}
item = (char*) malloc(item_length);
sprintf(item, "%d%s", arr[i], (i < size - 1) ? separator : "");
strcat(str, item);
}
Pol
A bit verbose, but this is definitely better I think.
Pol
I can even remove the strlen(separator) out of the for loop.
Pol
Ok I'll continue tonight, thanks for unblocking me Danya !
\Device\NUL
Danya🔥
Fetheddine
Fetheddine
Fetheddine
Like you can say i want. To make real project in c what can ido
Ayomide
Fetheddine
Fetheddine
In the course iwas following it was sdl nd its compatible with c but now its sdl2 nd it uses c++
Fetheddine
Fetheddine
While i search in google they say you can make everything in c. But how can i do it.
Fetheddine
Maybe just a little game in a window or idk i juste want to work on a window programm not a console one
J
Iwant to code in c
Download SDL2 lib and headers from SDL2 website. Import(include) the header files in your C project. Call the handlers to SDL2 library in your main() in C. When compiling, don't forget to link SDL2 libs against your C program.
Fetheddine
J
Can you show me how exactly or if you have a video or a documentation
Sure.
https://gist.github.com/fschr/92958222e35a823e738bb181fe045274
Even though the example has .cc(c++) extension, it is C styled C++. (for example, it uses printf instead of c++ specific cout and etc...). You can copy it to your main.c file, compile it and run it as a C program since it uses C functions.
J
ADDAD Fetheddine https://www.parallelrealities.co.uk/tutorials/
Fetheddine
Fetheddine
And do you have any other idas about c uses
J
And do you have any other idas about c uses
C? You can use it for system programming, create drivers, develop kernels, emulation, literally anything. Same can be said about C++ or other compiled, programming languages(w/o Garbage collector)
Anonymous
writing your own system in C is the highest goal
Anonymous
I think
$ameer
Any body here who can help me how can I run cop code in Ubuntu in vscode
Fetheddine
Fetheddine
Anonymous
i think must be a life
Fetheddine
Fetheddine
Cause it take milions of line of code
Fetheddine
So i want a small project to start manipulating programming in c
Anonymous
great
Fetheddine
Idk what to do
Anonymous
u can went to github to find a suitable small project
Anonymous
But in fact, it's hard to find
Fetheddine
So i have to go to c++ then
Fetheddine
Thats where i can do complete desktop app
Anonymous
hhh,maybe, but many beginners don't know how to do it at the beginning
Anonymous
Unlike Java, a beginner can make a small e-commerce system
Fetheddine
So in our time c nd c++
Fetheddine
I just for studie purpose
Fetheddine
Study*
Fetheddine
Cause its hard to use them today and it has better way to do our job Thats it?
Anonymous
But I think C / C + + programmers have a natural advantage
Anonymous
That is, the understanding of the bottom
Fetheddine
Yeah thats it
Fetheddine
But to make projects or freelance
Fetheddine
We need the. High level language
Anonymous
rust?
Fetheddine
Now i understand
Fetheddine
Anonymous
project like what bruhh
Fetheddine
Ireally dont know
Anonymous
Python
Anonymous
I recently learned
Fetheddine
project like what bruhh
Iwanted to practice in c. And the conclusion is we cant cause its hard and its doesnt have any advantage now
Fetheddine
Python
Its easy compared to c and c++
Anonymous
yes