When i compile my program is should compile but instead it comes up with a bunch of errors. I am using Dev-C++ 4.
here is my code:
And here are the errors:Code:#include <ctime>
#include <time.h>
#include <iostream>
#include <stdlib.h>
using namespace std;
int main()
{
string allcards[52] = {"2c", "2d", "2h", "2s", "3c", "3d", "3h", "3s",
"4c", "4d", "4h", "4s", "5c", "5d", "5h", "5s",
"6c", "6d", "6h", "6s", "7c", "7d", "7h", "7s",
"8c", "8d", "8h", "8s", "9c", "9d", "9h", "9s",
"10c", "10d", "10h", "10s", "Jc", "Jd", "Jh", "Js",
"Qc", "Qd", "Qh", "Qs", "Kc", "Kd", "Kh", "Ks",
"Ac", "Ad", "Ah", "As"};
srand(time(NULL));
int cardnum = rand() % 52;
string card = allcards[cardnum];
cout << card;
system("PAUSE");
return 0;
}
c:\my documents\trav's folder\c++ programs\cardss.cpp: In function `int main()':
c:\my documents\trav's folder\c++ programs\cardss.cpp:8: `string' undeclared (first use this function)
c:\my documents\trav's folder\c++ programs\cardss.cpp:8: (Each undeclared identifier is reported only once
c:\my documents\trav's folder\c++ programs\cardss.cpp:8: for each function it appears in.)
c:\my documents\trav's folder\c++ programs\cardss.cpp:8: parse error before `['
c:\my documents\trav's folder\c++ programs\cardss.cpp: At top level:
c:\my documents\trav's folder\c++ programs\cardss.cpp:15: ANSI C++ forbids declaration `srand' with no type
c:\my documents\trav's folder\c++ programs\cardss.cpp:15: `int srand' redeclared as different kind of symbol
C:\DEV-C_~1\INCLUDE\stdlib.h:272: previous declaration of `void srand(unsigned int)'
c:\my documents\trav's folder\c++ programs\cardss.cpp:17: syntax error before `='
c:\my documents\trav's folder\c++ programs\cardss.cpp:18: syntax error before `<'
c:\my documents\trav's folder\c++ programs\cardss.cpp:19: ANSI C++ forbids declaration `system' with no type
c:\my documents\trav's folder\c++ programs\cardss.cpp:19: `int system' redeclared as different kind of symbol
C:\DEV-C_~1\INCLUDE\stdlib.h:283: previous declaration of `int system(const char *)'
c:\my documents\trav's folder\c++ programs\cardss.cpp:19: initialization to `int' from `const char *' lacks a cast
c:\my documents\trav's folder\c++ programs\cardss.cpp:20: parse error before `return'