Shivansh
<stdin>:21:14: error: no viable conversion from 'SDL_Surface *' to 'SDL_Surface' SDL_Surface surface = TTF_RenderText_Solid(font, text, color);
Supernoobuser
Any guide about winsock2. h
Supernoobuser
what Ide do you recommend me for C. in windows
Shivansh
Shivansh
Any Suggestion that how I can improve this filehandling code
01000001011011010100000101101110
noop
<stdin>:21:14: error: no viable conversion from 'SDL_Surface *' to 'SDL_Surface' SDL_Surface surface = TTF_RenderText_Solid(font, text, color);
It says that in line 21, you cannot convert SDL_Surface to *SDL_Surface. So, I guess you need to modify it like this: SDL_Surface *surface = ...; And you should make sure to delete all the allocated memories.
Shivansh
Ok lemme se if I can correct it
Shivansh
#include <stdio.h> #include <SDL2/SDL.h> #include <SDL2/SDL_ttf.h> // Function for loading font and drawing text into SDL_Texture static SDL_Texture *loadText(SDL_Renderer *renderer, const char *text) { if (TTF_Init() == -1) { fprintf(stderr, "TTF_Init Error: %s\n", TTF_GetError()); return NULL; } TTF_Font *font = TTF_OpenFont("/system/fonts/Roboto-Regular.ttf", 256); if (font == NULL) { fprintf(stderr, "TTF_OpenFont Error: %s\n", TTF_GetError()); return NULL; } SDL_Color color = {255, 255, 255}; SDL_Surface *surface = TTF_RenderText_Solid(font, text, color); SDL_Texture *texture = SDL_CreateTextureFromSurface(renderer, surface); SDL_FreeSurface(surface); if (texture == NULL) { fprintf(stderr, "SDL_CreateTextureFromSurface Error: %s\n", SDL_GetError()); return NULL; } return texture; } int main(int argc, char *argv[]) { if (SDL_Init(SDL_INIT_EVERYTHING) != 0) { fprintf(stderr, "SDL_Init Error: %s\n", SDL_GetError()); return 1; } SDL_Window *window = SDL_CreateWindow("Hello SDL2-ttf", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, 0); if (window == NULL) { fprintf(stderr, "SDL_CreateWindow Error: %s\n", SDL_GetError()); return 1; } SDL_Renderer *renderer = SDL_CreateRenderer(window, -1, 0); if (renderer == NULL) { fprintf(stderr, "SDL_CreateRenderer Error: %s\n", SDL_GetError()); return 1; } SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "2"); SDL_Texture *textTexture = loadText(renderer, "Hello, world!"); if (textTexture == NULL) { fprintf(stderr, "Couldn't load text texture\n"); return 1; } int tw, th; SDL_QueryTexture(textTexture, NULL, NULL, &tw, &th); int w, h; SDL_GetRendererOutputSize(renderer, &w, &h); SDL_Rect dest; dest.x = 0; dest.w = w; dest.h = th * w / tw; dest.y = (h - dest.h) / 2; SDL_RenderClear(renderer); SDL_RenderCopy(renderer, textTexture, NULL, &dest); SDL_RenderPresent(renderer); SDL_Delay(5000); SDL_DestroyWindow(window); SDL_Quit(); return 0; }
Shivansh
This is correct 0 warnings & 0 errors
noop
This is correct 0 warnings & 0 errors
Make sure to take care of memory leaks if there is any
SHUBHAM
Hii
Dwyne
Anyone having coding ninjaas comptetive course videosa
Рома
Maybe someone know how to fix it
Рома
priority_queue<int>& mC(stack<int> st, priority_queue<int> pQ) { if (pQ.empty() && st.empty()) return priority_queue<int>(); }
Рома
Yes, but it doesn't even let me do that.
Рома
Yea
Рома
but what if I want return & to container
Рома
Ok, thx
Рома
Sorry for my stupid questions _ )
Рома
Ok, thank you for your understanding.
Abhishek Singh
Any resources for C++ STL
Alessandro
Is There someone who can help me with an error on visual studio when compiling?
Anonymous
Ok
Alessandro
Is There someone who can help me with an error on visual studio when compiling?
i'm not an expert in c++, and I'm lerning by myself, so if I say something stupid don't be angry with me.😕 The error is: error LNK2019: riferimento al simbolo esterno _listen@8 non risolto nella funzione _main fatal error LNK1120: 1 esterni non risolti
Anonymous
Hi
Anonymous
Ok give me one minute
Probably the problem is that you have a declaration (prototype) of the function but no definition — the actual code of the function
Anonymous
Hi
Any person here can do blogging in C/C++? Please contact me.
Anonymous
Ronak 🇮🇳
Sorry I gotcha😅
Alessandro
Ok
Anonymous
Use gist.github.com and send link here
Alessandro
I have to register there
Anonymous
I have to register there
Ok, use pastebin or smth
Alessandro
Ok, use pastebin or smth
no problem, I'm signing up
Anonymous
First
Francisco
no problem, I'm signing up
You'd better use Compiler Explorer. It's the de facto for online C++ coding
Alessandro
First
I've checked and i defined and then declared
Alessandro
It's hard to use from mobile
I'm Using my PC, but anyway, I'm on my repository on github, how do I share that with you?
Nils
std::map<std::string, std::string> get_post_files(GumboNode *node) { std::vector<std::string> fileurls; std::vector<std::string> filenames; return {filenames, fileurls}; } This throws an error: https://hastebin.com/ifobajaguy.cpp Any idea?
Nils
ohhhh nvm
Nils
I was blind
Anonymous
I'm struggling with a question
Anonymous
Can i get help here?
Anonymous
I'm new to C++ so i need help
Dima
Welcome, but read the rules please
Anonymous
I show you what I've worked on and the question and only then can you help me if my syntax is messed up?
Anonymous
👍
Sasuke
I have completed the c prime plus book I have basic knowledge of C. Which book should I read next to be get more info?
Dima
read the rules
Daemon
I have zero knowledge in programming, but have great interest and bit of knowledge regarding computers from where should i start i mean from which book should i start or any specific course i should take
Dima
first of all, never take courses
Dima
practice yourself, read books
Daemon
any good book from which i should start to learn basic functions
Anonymous
Actually think it's easier the other way around. To start from abstaction -> a high level managed language like java for example and work your way down from there. Depends on how you learn but for me it's easier to start with abstaction and then start to go into the details more and more
Anonymous
You will learn a lot of stuff and go for some challenges
Daemon
ok thanks for replies
Anonymous
Yeah, i know i took these courses. You are right you have to understand that but for me it was easier going in to c++ already knowing java, since you could focus on the memory management etc. and dont have to learn about loops, calsses etc. since you know that already. Really is personal preference how one learns faster.
Ronak 🇮🇳
How many days you took to understand these books?
devil
I want to learn coding
Dima
www.google.com
Ronak 🇮🇳
Yeah it is.
Samet
After getting the temperature value in 7 days of the week in c programming, I have to take the temperature values on the days of 2 weeks and 3 weeks.
Anonymous
function try blocks on constructors rethrow the current exception if something is not manually thrown before reaching the } of a catch
Anonymous
no :/
Anonymous
sure
Francisco
Just run it
devil
I want to learn c++. So help me start with beginning.
Dima
google can help
Dima
and books
Anonymous
Hi any one can help me i want book! to the beginer in c++
Dima
#cbook