Anonymous
price only exists in the base class. not anywhere else
Anonymous
i can replace the internals of the overridden functions with direct usage of price
Anonymous
yes
Anonymous
okay
Anonymous
thanks
Serenity
Hello guys, I would like to get some help with quite a simple problem.
Serenity
I have two strings, and I need to find out if the second string is a substring of the first string and delete it from the main string ( the first string) , if it shows up multiple times then I have to remove all the occurrences.
Serenity
I managed to confirm that one string is a substring of the other but as I one want to remove it , I encounter some issues.
Serenity
C
Serenity
and the usage of library functions is forbidden , that is the main goal of the exercise.
Serenity
I am at that point right now - I can surely check out if any given string is a substring of the other, do you have any idea how to think about tackling the second problem ?
Serenity
Yes
Serenity
and if it appears a several times then I need to remove all its occurrences
Serenity
I can post my code but it's some sort of awkward , I don't want to be a burden.
Serenity
I'll upload it anyways.
Serenity
https://pastebin.com/raw/zEgyUjRz
Serenity
it obviously returns 1 if the substring exists and 0 if it does not.
Serenity
I do not want to abort the function once I find an occurrence of the substring because it may appear multiple times along the original string.
Serenity
I know that my code is messy and unorganized , I'm totally amateur.
Serenity
Do I need to iterate through the string again ?
Serenity
I am pretty baffled about it because I use nested loops.
Serenity
I would rather do that separately so I can keep track of my code.
Serenity
Thanks a lot for guiding me through that
Anonymous
Hello guys r u interested in learning c++ from beginning thn dm me
Dima
sounds like lame
Dima
gotta take money from these people?
Dima
bad!
Dima
attention seekers lol
Dima
fseek(std_attention)
klimi
attention? *sniff sniff*?
klimi
gimme your paw
*gives paw*
Shivansh
Hii
Anonymous
not really. Quote -> T -> Bulk_quote (with no extra features over T) T -> Limited_bulk_quote is similar to Quote -> Bulk_quote -> Limited_bulk_quote
Anonymous
Samet
Hello can someone help me about C
Anonymous
Hello can someone help me about C
"Please read the pinned message 🙂" "I've read the rules and I agree with them."
Anonymous
Who taught you that?
Anonymous
Who taught you that?
nobody, but it looks like i can blame GNU
Anonymous
They use snake_case for classes, not Snake_case
Shivansh
What are memory leaks
Anonymous
Is it so hard or what?
Anonymous
oh. I just started the inheritance chapter. haven't overridden anything other than functions yet.
Anonymous
T can have a data member like limit (for lack of a better name) and it (it = limit?) will be an abstract class and this can be overridden by both Bulk_quote and Limited_bulk_quote.
Anonymous
oh by "it" you meant T. i thought you meant limit. idk what abstract class is yet. it's in the next section.
Anonymous
i'm 15 chapters deep atm. lemme refactor after finishing the book ;-;
Anonymous
I can't ask because I just got in ?
the pinned post has links on how to ask the right questions
Anonymous
C++ Primer by Lippman. no i iz nub
Samet
Samet
How can ı made this on C
Dima
LOL
Samet
Artöm
Accumulate both sum and addend in cycle 1 to n
Samet
I have one more question I need to get a yes or no answer and tie it to the if Condition How do I do that
klimi
How can ı made this on C
its simple math problem ... i think
klimi
its just 0+1+2+3+4+5+...+n
klimi
or maybe not... idk
klimi
i lack sleep
Nils
std::vector<std::string> merge_strvects(std::vector<std::string> &base, std::vector<std::string> &addition) { std::vector<std::string> newvect; newvect.reserve(base.size() + addition.size()); newvect.insert(newvect.end(), base.begin(), base.end()); newvect.insert(newvect.end(), addition.begin(), addition.end()); return newvect; } Do you think this is okay? Do you know a better way to solve this?
Anonymous
Which is better, project euler pr leetcode?
Anonymous
or*
klimi
ya geometric something something
Nils
Thank you!
Patrick
A smartphone is a computer
Dero
why not?
Ronak 🇮🇳
I wanted an explanation from you, you think never googled it before.
Shivansh
Can someone help me with this error #include <stdio.h> #include <SDL2/SDL.h> #include <SDL2/SDL_ttf.h> 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; } // Better scaling quality 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
Can someone help me with this error #include <stdio.h> #include <SDL2/SDL.h> #include <SDL2/SDL_ttf.h> 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; } // Better scaling quality 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; }
Anyone can help? ?
noop
Anyone can help? ?
What kind of error do you get?
Shivansh
Ok i will paste error message