You are viewing our Forum Archives. To view or take place in current topics click here.
need help with my C++ code (+rep)
Posted:
need help with my C++ code (+rep)Posted:
Status: Offline
Joined: Oct 21, 201014Year Member
Posts: 314
Reputation Power: 19
Status: Offline
Joined: Oct 21, 201014Year Member
Posts: 314
Reputation Power: 19
hi when i compiled my code i got an error but i dontknow how tofix it and u please help me
I believe is something about an undeclaired function but i thought i did that please correct me thanks guys
/*
*** COMPILING WITH DEV C++ 4.9.9.2 ***
*/
#include <windows.h>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
using namespace std;
int main(int argc, char *argv[])
{
int a;
string array [42] = {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","0","1","2","3","4","5","6","7","8","9", " ", " ","?","!","#","*"};
system("TITLE The Matrix");
system("color 0A");
while(1)
{
Sleep(45);
for(int i=0; i<27; i++)
{
a = rand()%42;
cout << " " << array[a]; <---- This is where
cout << " ";
}
cout << endl;
}
getch();
return 0;
}
*** COMPILING WITH DEV C++ 4.9.9.2 ***
*/
#include <windows.h>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
using namespace std;
int main(int argc, char *argv[])
{
int a;
string array [42] = {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","0","1","2","3","4","5","6","7","8","9", " ", " ","?","!","#","*"};
system("TITLE The Matrix");
system("color 0A");
while(1)
{
Sleep(45);
for(int i=0; i<27; i++)
{
a = rand()%42;
cout << " " << array[a]; <---- This is where
cout << " ";
}
cout << endl;
}
getch();
return 0;
}
I believe is something about an undeclaired function but i thought i did that please correct me thanks guys
#2. Posted:
Status: Offline
Joined: Jul 23, 201014Year Member
Posts: 3,091
Reputation Power: 159
Status: Offline
Joined: Jul 23, 201014Year Member
Posts: 3,091
Reputation Power: 159
cout << " " << array[i];
Try that?
- 0useful
- 0not useful
#3. Posted:
Status: Offline
Joined: May 30, 201014Year Member
Posts: 269
Reputation Power: 11
Status: Offline
Joined: May 30, 201014Year Member
Posts: 269
Reputation Power: 11
You never declared the variable "a" before the loop.
- 0useful
- 0not useful
#4. Posted:
Status: Offline
Joined: Jun 12, 201014Year Member
Posts: 531
Reputation Power: 33
MillerLite wrote You never declared the variable "a" before the loop.
It's declared at the very top.
This compiled fine for me:
#include "stdafx.h"
#include <windows.h>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int a;
string array [42] = {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","0","1","2","3","4","5","6","7","8","9",
" ", " ","?","!","#","*"};
system("TITLE The Matrix");
system("color 0A");
while(1)
{
Sleep(45);
for(int i=0; i<27; i++)
{
a = rand()%42;
cout << " " << array[a];
cout << " ";
}
cout << endl;
}
getch();
return 0;
}
The only change I made was including another header file, but it compiles and runs just fine.
- 0useful
- 0not useful
You are viewing our Forum Archives. To view or take place in current topics click here.