Ok so I am doing homework and they want me to use a clock to tell the difference in speed when using cout vs printf. They provided me with code to start and every time I run there code I get this. I put it into two posts because I could not get the whole thing in on screenshot. And I don’t know how to post pictures
So somehow it is deleting the first character of my line ever time it prints. And I don’t understand what is wrong because I didn’t write this my instructor did all I did was include stafx.h so it would run.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include "stdafx.h"
#include <iostream>
#include <time.h>
usingnamespace std;
int main()
{
double start, stop;
start = clock();
for (int i = 0; i<100; i++)
{
cout << " The number is " + i << endl;
}
stop = clock();
cout << "It took " << (double(stop - start) / CLOCKS_PER_SEC) << " seconds for cout" << endl;
cin.ignore();
}