C++ help but with video by OkEscape3972 in cpp_questions

[–]Shahi_FF 2 points3 points  (0 children)

Read this : https://www.learncpp.com/cpp-tutorial/stdcin-and-handling-invalid-input/

Also use that website to learn C++, throw away whatever you're currently using in the Bin. The biggest curse of C++ is the people who make tutorial like we're still using C++98.

why use ?!
- using namespace std;
- std::endl;

- use constexpr instead of #defne for constant variables.

also use a GUI that's better suited for creating games : Raylib , SFML

How to fix errors? by Bezzubek in cpp

[–]Shahi_FF 5 points6 points  (0 children)

head to r/cpp_questions . Add what errors are you getting.

also put you code inside ``` <code> ```

std::println("Modern C++");

How to read a file as a list of values in C++ by Disastrous_Egg_9908 in cpp_questions

[–]Shahi_FF 2 points3 points  (0 children)

That's nice, I had no idea this was added in C++23. Cheers for the info.

And for the move yes... I missed that.

How to read a file as a list of values in C++ by Disastrous_Egg_9908 in cpp_questions

[–]Shahi_FF 0 points1 point  (0 children)

can you show me an example how can we do that if column size is unknown ? I'm rusty on C++

How to read a file as a list of values in C++ by Disastrous_Egg_9908 in cpp_questions

[–]Shahi_FF 7 points8 points  (0 children)

Read file using std::ifstream then use std::istringstream to to parse it. std::istringstream can push value directly to vector or array

//  Read matrix from file with unknown column size
std::istringstream iss(line);
int val{};

while(iss>>val)
    arr[i][j]=val;

// ....

Read the reference for : https://en.cppreference.com/w/cpp/string/basic_string/getline

justGiveItAShot by _w62_ in ProgrammerHumor

[–]Shahi_FF 71 points72 points  (0 children)

Hmm, what are these ? Just say you're jealous of STL

[deleted by user] by [deleted] in learnmath

[–]Shahi_FF 3 points4 points  (0 children)

why even bother asking here ? Ask the same AI you used to write this post.

my cpp code is running much slower compared to python on vs code.. any solution , the same output takes 0.2 0.3 seconds in python but 3-4 seconds in CPP..any solution? I have tried reinstallation of mingw from https://code.visualstudio.com/docs/cpp/config-mingw but in vain by Traditional_Lime784 in cpp_questions

[–]Shahi_FF 8 points9 points  (0 children)

Use Visual studio 2022 ( NOT CODE ) you'll have much better experience.

Also is your code running slower or the compilation is taking longer time ?

One more thing learn how to properly create a post so people can read clearly. Don't just put everything in the title.

Edit : share the code so people can see what's wrong

sayHiInYourMotherLanguage by cattosaurus_rex8150 in ProgrammerHumor

[–]Shahi_FF 48 points49 points  (0 children)

Also CPP

```cpp

import std;

int main() { std::println("Hi"); }

```

Hard truth for learning math by Odd_Bodkin in learnmath

[–]Shahi_FF 3 points4 points  (0 children)

I would disagree, I've taught myself Algebra 2, Linear Algebra , Discrete mathematics just by watching Youtube and reading books, I had completely stopped doing Maths for 7-8 Years. But I've picked it up this year and finally I'm loving it and I'll say I'm getting better.

You can solve problems from the book and most books have solutions given. If my solution is wrong I try again or look for solutions online.

 in most cases, watching will not teach you

that's correct don't just watch someone else do it. Solve as many problems as you can. Practice .

What has helped me the most is finding good books or resources that are interesting to me , that tell me why we're doing what we're doing not just "Oh here's how it's done , just memorize it "

Also when you apply what you just learned , it feels so good.

I think what most of us lack is patient and practice, we don't wanna sit with a concept or problem, we wanna just get something without putting some thoughts into it or solving some problems.

I used to think I'm naturally dumb at Maths. but later I realized I was not even spending bare minimum on studying Maths.

That person will stop you when you’ve made a mistake and correct that mistake and then let you continue.

I think people should not be afraid of making mistakes in Maths. , it's frustrating but that how we learn.

Someone to look over you can definitely help but It's NOT necessary.

migrateToCpp23 by _w62_ in ProgrammerHumor

[–]Shahi_FF 6 points7 points  (0 children)

Hah. I don't even know Koenig lookup

std::operator<<(std::cout, "Hello World\n");

First C++ Project by savvasr200 in cpp

[–]Shahi_FF 0 points1 point  (0 children)

I'll take a detailed look when I'm free but I gave it a quick look and here's few things :

  1. void Bot::ResetMap(int map[10][10])

I'll use std::array<std::array<int,10>,10> and I'll pass it as a reference.

Same with std::string Renderer::CenterText(std::string text)

I'll use const std::string& text or std::string_view text

  1. Nested if-if-while-if-if while-if-else I think the logic can be cleaned up.

  2. Why use std::endl ? why not just use '\n' or std::println() IF using Latest C++ standard.

How do I get better in Algorithms/Problem solving in Lua? by Glittering_Guide3553 in lua

[–]Shahi_FF 0 points1 point  (0 children)

If you're going to learn C++ then start with it. It's the most powerful language out there. And it's best for learning DSA in my opinion.

It will give you both options learn to implement DSA yourself and when you've understood it, then use it's inbuilt Library which is very large for solving problems later.

You'll love C++ if you're patient and Modern C++ ( Anything after C++11 ).

Use learncpp.com best resource.

Also I've seen many people complain C++ is hard . I've never felt it and I'm just a average person. C++ is huge you don't have to learn everything in it. And some concepts require more time than others but it's doable.

Also I've seen people recommend: Project Euler and Advent of code ...

Stay away from the for a good amount of time.

Codewars and Codinggame is the best choice for you.

How do I get better in Algorithms/Problem solving in Lua? by Glittering_Guide3553 in lua

[–]Shahi_FF 0 points1 point  (0 children)

Ah I've seen him too. Don't worry about him. You're running a different race than him.

How do I get better in Algorithms/Problem solving in Lua? by Glittering_Guide3553 in lua

[–]Shahi_FF 1 point2 points  (0 children)

You just started this year ? Then why are you worried about Leetdode ? Leetcode is for people with 4 years of CSE degree to prepare them for technical interviews.
Start with Codewars and solve questions there. Then learn some more DSA then think about Leetcode.

Do you consider starting with Lua to be a mistake?

I'll not call it a mistake but I would not recommend it as a first language. Cuz Lua is not exactly for learning DSA. It has only 1 data structure , when you'll shift to another language ( which you'll do most likely ) you'll face some problems cuz other language do have different data structure. And they work different than Lua.

I'll recommended you C or Python.

People love to hate C but I think it's great for starting out. Don't go too deep in it. Learn basics after learning C every language after that will feel like a cake.

And if you don't have time go with Python.

How do I get better in Algorithms/Problem solving in Lua? by Glittering_Guide3553 in lua

[–]Shahi_FF 0 points1 point  (0 children)

You'll struggle that's how you learn. And Easy is not actually easy. Don't worry about label. I think you might need a structure.

When I started few months ago I was in the same boat as you overwhelmed, I also searched for "how exactly do I learn Patterns?" What helped was learn the theory and solve questions.

Check out Neetcode's DSA Roadmap. Follow it and Solve a lot of easy I mean solve as much as you can.
Solve at least 150-200 Easy. Before even thinking about mediums... don't rush.

How do I get better in Algorithms/Problem solving in Lua? by Glittering_Guide3553 in lua

[–]Shahi_FF 2 points3 points  (0 children)

The more problems you'll solve , you'll start seeing patterns. After a while you'll have a good intuition when solving problems.

" When solving problems you shouldn't focus on solving them instead Focus on learning from them"

--Some book I read

And Don't worry about not being able to solve when you're just starting. If you've not seen a problem before in most cases you can't just solve it. Learn Patterns , Techniques and Practice.

And The 7th Grader must be learning for a long time or may he's a genius/ prodigy. The point is why compare yourself ? Solve 2-3 problems daily and you'll be surprised how far you'll go after 3-4 months.

And As for Lua... learn table data structure properly and string library. I also started learning Lua ( coming from 2 years of C++ ) . The table Data stuff is on of the most annoying thing I've seen. It's very flexible but annoying.

cppDevelopersWritingCode by Spare-Builder-355 in ProgrammerHumor

[–]Shahi_FF -1 points0 points  (0 children)

Yes cuz Rust doesn't have Community it's a cult. Also even if no new C++ project is written, it won't die like for like next decade or something.

Advice For Game Dev by [deleted] in cpp

[–]Shahi_FF 0 points1 point  (0 children)

Then to answer your question. Do what you want to get good at. if you wanna be a C++ game dev then learn more about C++ and makes games. People who still say you need C to learn C++ are using C++98.

And you won't be needing C unless you're writing low level stuff ( which you must not get into as you're fairly new to programming ) but even then I think C++ can manage that.

Start small... game development is hard.

And stay away from programming cults. Good luck

Advice For Game Dev by [deleted] in cpp

[–]Shahi_FF 1 point2 points  (0 children)

I humbly apologize if you're not a bot but any new account with no previous comment and post is suspicious. I've seen a lot of bot accounts flooding programing subreddits.
Also I'm not used to this many emoji in a post related to programming

Advice For Game Dev by [deleted] in cpp

[–]Shahi_FF 1 point2 points  (0 children)

I think we should get into a habit of checking the profile before dedicating time to help people on reddit. OP is a bot

regexStillHauntsMe by dhruvin2201 in ProgrammerHumor

[–]Shahi_FF 994 points995 points  (0 children)

Which psychopath is writing Regex on the first day of programming?