help with this code

I know I got alot of unused stuff here but this will go into a larger program.

My problems are const int MAX_LIMIT and const int MAX_COPY they work with copyLimit and iam putting in 2000 entrys from a txt file. copyArray I'm using a file with 1723 entries. I got them both set to 512 and don't understand at all what or why that is. Also its like all my entries from the txt files are in copyArray. If I remove the other strings and MAX whatever that I'm not using I get a code 11 after a successful compile and run. I don't get it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#include <iostream> 
#include <string> 
#include <cstdlib> 
#include <ctime> 
#include <fstream>
#include <sstream>
#include <string>
#include <cstddef>
#include <iomanip>

using namespace std; 


//Sleep function

int msleep(unsigned long milisec)   
{   
    struct timespec req={0};   
    time_t sec=(int)(milisec/1000);   
    milisec=milisec-(sec*1000);   
    req.tv_sec=sec;   
    req.tv_nsec=milisec*1000000L;   
    while(nanosleep(&req,&req)==-1)   
        continue;   
    return 1;   
}   


int main()
{
	//Seed random number
	srand(static_cast<unsigned int>(time(0)));
	
	char line3[256];
	char exit[256] = "<EOF>";
	
	string userInput;
	string promptName = "[C$//]";
	string line;
	string line1;
	string output;
	string output1;
	string output2;
	string dirLoc;
	string dirLoc1;
	
	string myAddy = "jwlickliter@freedom.com";
	
	const int MAX_COM = 1024;
	const int MAX_DIR = 256;
	const int MAX_FILE = 256;
	const int MAX_NET = 1024;
	const int MAX_COPY = 512;
	const int MAX_LIMIT = 512;
	
	int errorCode = 0;
	int dirChange = 0;
	int thisData = 0;
	int increase = 0;
	int lineOut = 1;
	int newLineChecker = 0;
	
	int address1 = 0;
	int address2 = 0;
	int address3 = 0;
	int address4 = 0;
	
	int endNum1 = 0;
	int endNum2 = 0;
	int endNum3 = 0;
	int endNum4 = 0;
	
	
	
	string osCom[MAX_COM];
	string dirNames[MAX_DIR];
	string fileNames[MAX_FILE];
	string netCom[MAX_NET];
	
	string userDir[MAX_DIR];
	string user1Files[MAX_FILE];
	
	string copyArray[MAX_COPY];
	string copyLimit[MAX_LIMIT];
	
	//make computer id
	ifstream netfile1 ("/storage/emulated/0/MyGame/MyHackGame/jni/compList.txt");
	if (netfile1.is_open())
	{
		for (int i=0; !netfile1.eof(); i++)
		{
			getline(netfile1,line1);
			copyLimit[i] = line1;
		}
	}
	netfile1.close();
	
	//search internet
	
	ifstream net_file ("/storage/emulated/0/MyGame/MyHackGame/jni/internetList.txt");
	if (net_file.is_open())
	{
		for (int i=0; !net_file.eof(); i++)
		{
			getline(net_file,line);
			copyArray[i] = line;
			
			
		}
	}
	net_file.close();
	
	for (int i=1; i<11; i++)
	{
		int rndArr = (rand() % 1723);
		int rndArr1 = (rand() % 2000);
		int rndTime = (rand() % 15+10);
		int rndTime1 = (rand() % 5+1);
		
		msleep(rndTime);
		cout << std::flush;
		if (rndTime1 == 1 || rndTime1 == 2 || rndTime1 == 3 || rndTime1 == 5)
		{
			cout << "[" << i << "] " << copyLimit[rndArr1] << endl;
		}
		if (rndTime1 == 4)
		{
			cout << "[" << i << "] " << copyArray[rndArr] << endl;
		}
		
		cout << rndTime1 << endl;
	}
	
	
	
	
}


I edited the code a litte to explain more
This is the output I got. what's weird is the ones with comp-id are in copyLimit with 2000 entries. The others that are business names are in copyArray 1723 entries. this output dosnt make sense.

[1] 100.170.19.198 Comp-id{58wO6Jg102sH}
1
[2] 121.231.27.86 Comp-id{1HsOg260J85w}
5
[3] 28.207.23.127 Keller-Group
4
[4] 81.200.92.5 Devon-Energy-Corporation
1
[5] 77.172.138.169 Pulte-Homes-Inc
2
[6] 139.56.149.71 Protective-Life-Corp
2
[7] 142.53.123.75 Health-Net-Inc
2
[8] 217.237.142.79 Comp-id{51s0H8g6wO2J}
1
[9] 55.22.211.59 US-Industries-Inc
5
[10] 169.92.98.22 Gap-Inc
1
Last edited on
Just a quick look at the if statements should tell anyone I should have only one business name with a ip and the rest should be comp-id with ips. This is real important I get this working cause this is my fake internet in my game.
Check this weird stuff out. if I comment these out it compiles and runs but the output is process exited with code 11. Wtf dose this matter? These aren't being used. I have to have unused stuff in my code for it to run?


//const int MAX_COM = 1024;
//const int MAX_DIR = 256;
//const int MAX_FILE = 256;
//const int MAX_NET = 1024;

//string osCom[MAX_COM];
//string dirNames[MAX_DIR];
//string fileNames[MAX_FILE];
//string netCom[MAX_NET];

//string userDir[MAX_DIR];
//string user1Files[MAX_FILE];
Last edited on
Topic archived. No new replies allowed.