Fetheddine
Wait
Fetheddine
The course iwas followin is an old one so its about sdl one
Fetheddine
And the main have to look lik this
Anonymous
😂I've seen many beginners of C + + use C style when writing programs,the only possible change is that printf becomes STD:: out
Fetheddine
Icant send pics here
Anonymous
such as struct,Instead of using classes, they use function methods externally, just like C
Anonymous
I am learning oop for C++
Anonymous
on classes
Fetheddine
such as struct,Instead of using classes, they use function methods externally, just like C
Conclusion my problem isnt here my problem is that course is old and many fonctions does not exist anymore so i need a documentation on sdl2 in c language
Danya🔥
#ot
Danya🔥
Go here
Anonymous
There seems to be a C interface
Anonymous
good
J
Conclusion my problem isnt here my problem is that course is old and many fonctions does not exist anymore so i need a documentation on sdl2 in c language
Like I said, it is literally copy pasting library, importing headers and writing the Code. (Since the C++ code in most tutorials for SDL2 are C styled since SDL2 is a C API) For example, main.c // SDL2 Hello, World! // This should display a white screen for 2 seconds // compile with: clang main.cpp -o hello_sdl2 -lSDL2 // run with: ./hello_sdl2 #include <SDL2/SDL.h> #include <stdio.h> #define SCREEN_WIDTH 640 #define SCREEN_HEIGHT 480 int main(int argc, char* args[]){ SDL_Window* window = NULL; SDL_Surface* screenSurface = NULL; if (SDL_Init(SDL_INIT_VIDEO) < 0) { fprintf(stderr, "could not initialize sdl2: %s\n", SDL_GetError()); return 1; } window = SDL_CreateWindow( "hello_sdl2", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN ); if (window == NULL) { fprintf(stderr, "could not create window: %s\n", SDL_GetError()); return 1; } screenSurface = SDL_GetWindowSurface(window); SDL_FillRect(screenSurface, NULL, SDL_MapRGB(screenSurface->format, 0xFF, 0xFF, 0xFF)); SDL_UpdateWindowSurface(window); SDL_Delay(2000); SDL_DestroyWindow(window); SDL_Quit(); return 0;} Here, I just changed main.cc to main.c since the tutorial literally uses C styled Cpp or basically a C program. https://gist.github.com/fschr/92958222e35a823e738bb181fe045274
Anonymous
I just went to see the API
Anonymous
It seems that it is indeed a C-style API, but it is not guaranteed that what I see is backward
Anonymous
Okay
Anonymous
In fact, I didn't learn many things. The more I study, the more I can know my ignorance
Fetheddine
SDL2 is written in C.
Yeah but its changed to be more compatible with c++
Anonymous
Ask your question
J
Yeah but its changed to be more compatible with c++
Like I said before. It is a C library, written in C. C++ can use this library because C++ supports C styled programming and iirc, there are no native bindings for SDL2 to C++. A pure C game engine using SDL2 for windowing https://github.com/eduard-permyakov/permafrost-engine
J
Yep but now theyre devloping it to be more compatible with c++
🤦I used that library in the past(maybe 6 months before). I didn't use it with C or C++. I used it with Zig(A programming language like C, made to replace C). How? Creating wrappers around C API. (Or TBN, it is very much compatible with C because it is made in C so that other languages can create wrappers). And like I said before, C++ can call C library without any additional tweaking. That is why there is no SDL2-C++ with classes and namespaces or other things.
Fetheddine
Wdymn by creating wrappers
J
Wdymn by creating wrappers
codes that literally wrap around other program components. pub fn init(flags: InitFlags) !void { if (c.SDL_Init(flags.as_u32()) < 0) return makeError(); } Now, if in my program, I can just do init(_) instead of doing all those stuffs in the init()//Since we are calling a function from another programming language. (Consider it as it is to make sure calls are more native to the programming language I am using)
Fetheddine
Thank you so much
Natanim
hello, i havent studied object oriented yet and i need help in changing from objects and classes to functions without classes in c++ can anyone help me in pm?
Евгений
Books. It's so easy.
klimi
if it was urgent, you would have said your problem and just not spam by pm request
Anonymous
haha,That's true
Anonymous
You can explain your problem directly
Natanim
i cant send the file here
Anonymous
URL?
Natanim
no its a code file
Natanim
exe
Anonymous
Files cannot be sent here
Natanim
and the code is too long
Anonymous
Can u push to GitHub and send the URL?
Anonymous
I think this is a good solution
Natanim
ok a minute
X
Hey admins, may I share my video in this group about C programming ?
Natanim
I think this is a good solution
https://github.com/VickTheKid/Hotel-reservation.git
Anonymous
You want to turn it into the form of oop?
Natanim
You want to turn it into the form of oop?
i want to remove the classes and objects, and i want to use only functions, loops, arrays and stuff
Anonymous
You can use struct,same as C
Anonymous
there are only members in struct
Natanim
Anonymous
Is that the only thing you're allowed to say
Anonymous
I'm sr, I seldom use function pointers. Maybe I can't help you
Kevin
good morning
J
https://github.com/VickTheKid/Hotel-reservation.git
Looking at your code, it's actually easy to do. Make those class variables(parameters) global, make class functions(associated functions) as normal functions. Then call those from the switch statement in main_menu()
Anonymous
That's a great idea
Danya🔥
Why.. just why.. why do you want to uglify the code?
Anonymous
C++ without classes, I don't know how to write code
Danya🔥
Anonymous
Hello guys.
Anonymous
I was learning how to code a socket program in C. And i did it but i have a problem in my client code that i can't fide it and it's totally true . I am really confused. Can someone help me?
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
Hi guys, I'm writing two softwares, the former a Server program, the latter a Client program in Unix environment (using C). The client program uses a named PIPE (that is, a FIFO) in order to "talk" to the Server program. This one uses the FIFO on the "reading side". The problem is, I think I have to do something with the stdin in order to make every input from the client program go directly into the PIPE, thus for the server program reading it directly from the other edge of the FIFO, am I wrong? I mean, I wrote: close(0) (which is stdin); dup(FIFO_fd); (where int FIFO_fd= open(FIFO_NAME, O_RDONLY); But I don't know if I am doing it correctly. Since I closed the 0 entry in the process descriptor table, the dup operation should "allocate" the duplicated channel (that is, FIFO_fd) to the first available entry in the table, which is the 0. Thus the question: do I really need to do this? Or is it enough to open a FIFO on both Server and Client program and they'll talk automatically? Thanks!
Shubh Joshi
Hello everyone I want to learn about linked list from very basics So please suggest website and some video tutorials to learn from basics Thanks in advance 👍
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
Linked lists are so easy that is very difficult to find bad videos; nevertheless, I advice Neso Academy's videos on YouTube, he is very good, I studied Computer Architecture and Algo & data structs with his videos
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
Focus on the free() detail when deleating a node from a list. About delete(), it's very easy on double linked lists, instead you need some "pointer magic", let's say, with the single linked lists. Neso should explain them all, but in case he doesn't, just remember to search for these topics in particular, they are very important
Shubh Joshi
Ok Got it👍Thank You so much👍
Anonymous
C primer plus can help
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
Artur
An interesting source here, could be useful for newbies
Artur
https://hackingcpp.com/cpp/cheat_sheets.html#hfold5a
Artur
/admin have a look at it
Kevin
for(int i=1;i<=n;++i,a=b){ cin>>b; if(a==b){ r=i-1; if(l==1) l=i;