r/CodingForBeginners • • 6d ago

Day 5 of learning C++(first program)

Post image

Today , i finally completed my 1st module on learncpp.com

Learnt literals , operators , expressions made two programs(only took ss of one Program)(and yeah I added new line character afterwards)

Well as I know some coding so it was pretty easy

Tbh the hardest part was to figure out what CMakeList is in CLion

Spend more time in figuring and setting that up rather than coding

+ If anyone know how to like automatically add executable in CMakeList rather than adding manually , well adding manually is not a problem tho but still

Tomorrow will be hectic day(college assignments and practicals) still will try to do some coding.

113 Upvotes

17 comments sorted by

View all comments

4

u/kutac56 6d ago

You can do int x; instead of int x {};, you are using namespace std and then still typing std:: and you also don't need cmake as that is mainly for cross platform building which is not necessary for such simple things (compile with g++ foo.cpp -o foo)

2

u/samosa285 5d ago

Tbh I didn't know about what using namespace std does I was just messing around And about cmake without adding it CLion was saying that executable file cannot be created blah blah

1

u/[deleted] 4d ago

Have using namespace std just allows you to use the comment and statements without needing to use std. I don't know the full capabilities of it, but if you use namespace, you don't need std.

But yeah, using the -o is pretty cool if you want to make your own file names, without having to use ./a.out