You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 24, 2019. It is now read-only.
#0.2 Hello World (iteration statements, pointers, make)
hello, world is a classic program that dates back to 1974, first published in
a paper titled Programming in C: A tutorial. The program has one simple
purpose; to print "hello, world".
Since the typical implementation is very trivial, your task is to write a more
versatile alternative, having the following semantics:
$ ./hello
Hello, world!
$ ./hello "DD2387"
Hello, DD2387!
$ ./hello "KTH" 3
Hello, KTH KTH KTH!
$ ./hello "Malcom X" NaN
error: 2nd argument must be an integral greater than zero!
$ ./hello kth dd2387 3
error: Too many arguments!
Note: This assignment is not an exercise in object oriented programming (OOP),
but a mere introduction to the fundamental parts of C++.
0.2.1 Requirements
The main-function shall be written in a file called main.cpp.
You shall implement a function which is responsible for printing the hello
world string, which shall be defined in a separate .cpp file (Translation
Unit).
The separate .cpp shall have a corresponding .h-header that contains a
forward declaration for the function therein. This header is to be#included
by main.cpp.
The definition of your print-function shall be compiled seperately, and later
linked with main.cpp.
Correct output from your program should be printed through std::cout,
whereas error diagnostics should be printed through std::cerr.
The implementation shall pass the tests done by invoking the following
command:
Use an argument named argc to main to get the number of arguments passed
to your application. Remember that the name of the executable counts to this
number.
Use an argument named argv to main to get access to the individual
parameters passed to your application.
std::atoi from <cstdlib> can be used to convert a char const * to an
integer. If the function is unable to interpret the data as an integer, it
will return 0.
0.2.3 Questions
What is the purpose of std::cout, std::cerr, and std::clog,
respectively?
The text was updated successfully, but these errors were encountered:
cout is a stream that prints output to standard output (typically the
terminal the program is invoked from). It is meant for the main output from a
program. For instance, a program that copies files might print progress
information to cout.
cerr is a stream that prints to standard error (also typically the terminal
the program is invoked from). It is meant for error output, for instance a
program that copies files might print warnings and error information such as
permission issues to cerr.
clog is meant for log output, and is by default connected to standard
error. For instance, a program might print fine-grained debugging
information to clog.
#0.2 Hello World (iteration statements, pointers, make)
hello, world
is a classic program that dates back to 1974, first published ina paper titled Programming in C: A tutorial. The program has one simple
purpose; to print "hello, world".
Since the typical implementation is very trivial, your task is to write a more
versatile alternative, having the following semantics:
Note: This assignment is not an exercise in object oriented programming (OOP),
but a mere introduction to the fundamental parts of C++.
0.2.1 Requirements
The
main
-function shall be written in a file calledmain.cpp
.You shall implement a function which is responsible for printing the hello
world string, which shall be defined in a separate
.cpp
file (TranslationUnit).
The separate
.cpp
shall have a corresponding.h
-header that contains aforward declaration for the function therein. This header is to be
#included
by
main.cpp
.The definition of your print-function shall be compiled seperately, and later
linked with
main.cpp
.Correct output from your program should be printed through
std::cout
,whereas error diagnostics should be printed through
std::cerr
.The implementation shall pass the tests done by invoking the following
command:
0.2.2 Hints
argc
tomain
to get the number of arguments passedto your application. Remember that the name of the executable counts to this
number.
argv
to main to get access to the individualparameters passed to your application.
std::atoi
from<cstdlib>
can be used to convert achar const *
to aninteger. If the function is unable to interpret the data as an integer, it
will return
0
.0.2.3 Questions
std::cout
,std::cerr
, andstd::clog
,respectively?
The text was updated successfully, but these errors were encountered: