Sep 1, 2012 at 7:12pm UTC
This is a very simple program, I only have a stupid error and I don't see what's wrong...
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include <windows.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <fstream>
int main()
{
int n = rand() % 26;
char c = (char )(n+65);
cout << c << endl;
Sleep(10000);
return 0;
}
11 C:\Users\Mathijs\Documents\C++\test13.cpp `cout' undeclared (first use this function)
11 C:\Users\Mathijs\Documents\C++\test13.cpp `endl' undeclared (first use this function)
Last edited on Sep 1, 2012 at 7:13pm UTC
Sep 1, 2012 at 7:15pm UTC
you need to either put using namespace std; between #include <fstream> and main, or do std::cout, std::endl; cout and endl are part of the std namespace, without it you cant use either of those without errors.
Last edited on Sep 1, 2012 at 7:18pm UTC
Sep 1, 2012 at 7:18pm UTC
Crap, I always forget those small things....
Sep 1, 2012 at 7:19pm UTC
Lol i hear ya, i do the same stuff sometimes too.