cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
Store and Print string in C / C + +
Store and Print string in C / C + +
Sep 20, 2013 at 12:55pm UTC
Alby94
(63)
Given this sentence as an input: "Hello my name and "John" (with its spaces and capital letters), print it on the screen .. NB the phrase must be entered from the keyboard all at once ... you can do this in C / C + +?
Sep 20, 2013 at 1:25pm UTC
LB
(13399)
You can do it easily in C++, it is very difficult to do in C.
For C++, look up
std::string
and
std::getline
.
Last edited on
Sep 20, 2013 at 1:25pm UTC
Sep 20, 2013 at 1:30pm UTC
Duthomhas
(13125)
In C you've got the
getline()
and
getdelim()
GNU/POSIX functions:
http://linux.die.net/man/3/getline
You can also roll your own stuff:
http://www.cplusplus.com/forum/beginner/4174/#msg18271
Sep 20, 2013 at 3:17pm UTC
closed account (
jwkNwA7f
)
getline(): http://www.cplusplus.com/reference/string/string/getline/
Topic archived. No new replies allowed.