+ 2
In how many ways we can print a string in c++?
what are the different ways of printing a string in c++?
1 Answer
+ 1
Printing std::string str to stdout.
#include <cstdio>
std::puts(str.c_str);
std::fputs(str.c_str, stdout);
std::printf("%s", str.c_str);
std::fprintf(stdout, "%s", str.c_str);
for (int i=0; i < str.lenght(); ++i)
std::putc(str.at(i));
for (int i=0; i < str.lenght(); ++i)
std::fputc(std.at(i), stdout)
#include <iostream>
std::cout << str << std::endl;
These would be the main ways, but there are many more.