I have a string-typed deque initialised, and with a string in it, ie in my main function:
deque<string> d;
I know that I can use this to output using iostream library,
for(string n : d)
cout << n;
However, I know trying to use the cstdio library to output the string. One way that I know which works is
for(i = 0; i < d.size(); i++)
printf("%s", d.at(i).c_str());
However, that seems to be much slower than I thought (by means of submitting to an online judge), and thus I am wondering if there is a way to print the string using cstdio library in a way that is faster than the above!
Addendum: The code which mixed cstdio with iostream was the fastest, ie
scanf("%s", str);
s = string(str);
...
for(string n : d)
cout << n;
The second fastest was pure iostream, ie
cin >> s
...
for(string n : d)
cout << n;
The slowest was pure cstdio, ie
scanf("%s", str);
s = string(str);
...
for(i = 0; i < d.size(); i++)
printf("%s", d.at(i).c_str());
Addendum 2: I mentioned measurement of speed and in this case it was the output of "CPU speed" by the Kattis online judge after each submission of code. No other forms of measurement were used. Would it be true that for e.g., many users were submitting their codes at the same time, then CPU time would increase? I am ignorant on how it is measured, and thus posing this question at the same time.
Many thanks for any input.