I’ve just finished a course of C++ on w3schools to get my head around a bit of it. Due to the fact I had mostly experience with C# and I’m wonering about the syntax.
Within the course i was using the syntax for output as:
cout << “Insert text”;
over on Your course:
printf(“Insert Text”);
Why is there so much difference in between those aproaches.
printf() is a function from the C library that C++ is built on, and allows you to create a formatted string. For example (the exact syntax may be wrong): printf("Hello %s", name) could print “Hello Detherok” if name contained your name.
cout on the other than, is an addition added from the C++ library that can allow us to print text as a stream instead of using repeated function calls.
In the context of a small project they’re practically indistinguishable in function, but have their specific talents shine in larger projects.
C++ and other programming languages are going to have quirks like this, especially if they’re built upon other languages like C++ is. This can even happen when working with libraries, frameworks, and engines.