Reading CSV to Array Only Works in Debug?!

Hi all,

This has been driving me crazy for hours now. I'm using a CSV file to transfer data in a 300x300 array from one program to another. The program reading the CSV will use the data to populate and visualise a map in GLUT.

The only problem is the simple code used to read the data from the CSV to an array of floats only functions correctly in Debug mode (returns rubbish otherwise).

The main loop is shown below. The current solution is messy as a result of trying endless options, however still works in Debug. All I'm trying to do here is populate the array before I establish network connections and initialise the GUI. Any ideas on what might be wrong as highlighted by the fact this only works correctly in Debug?

Thanks,

Ed

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
int main(int argc, char **argv)
{


	ifstream inputFile ("occGridMap_mod.csv");
	int r, c;
	float rc;
	string value;
	//stringstream ss;

	//Load occupancyGrid from CSV
	for(r = 0; r < 300; r++)
	{
		for(c = 0; c < 300; c++)
		{
			getline (inputFile, value, ',');
			stringstream ss(value);
			ss >> rc;
			//rc = atof(value);
			occupancyGrid[r][c] = float(rc);
		}
	}
	inputFile.close();

	//Create socket
	sockfd = socket(AF_INET, SOCK_STREAM, 0);
	if (sockfd < 0)
		error("ERROR opening socket");
	bzero((char *) &serv_addr, sizeof(serv_addr));
	portno = atoi("51717");

	//Configure server
	serv_addr.sin_family = AF_INET;
	serv_addr.sin_addr.s_addr = INADDR_ANY;
	serv_addr.sin_port = htons(portno);

	//Bind socket
	if (bind(sockfd, (struct sockaddr *) &serv_addr,
		sizeof(serv_addr)) < 0)
		error("ERROR on binding");

	//Listen for incoming connection
	listen(sockfd, 5);
	clilen = sizeof(cli_addr);

	//GUI Initialisation
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGB);
	glutInitWindowPosition(0,0);
	glutInitWindowSize(800,600);
	glutCreateWindow("Probabilistic Occupancy Grid");
	glutDisplayFunc(display);
	glutMouseFunc(mouse);
	glutMotionFunc(motion);
	glutKeyboardFunc(key);
	glutIdleFunc(receive); //Declare receive() function as glut idle function
	glClearColor(1.0, 1.0, 1.0, 1.0);

	scale=0.0004;

	glMatrixMode(GL_PROJECTION);
	gluPerspective( 22.0, 1.0, 5.0, 10.0);

	glMatrixMode(GL_MODELVIEW);
	gluLookAt(0.0, 0.0, 5.0,  /* eye is at (0,0,5) */
	0.0, 0.5, 0.0,      /* center is at (0,0,0) */
	0.0, 1.0, 0.);      /* up is in postivie Y direction */
	glTranslatef(0.0, 0.0, -3.0);

	/* Give the object an "interesting" orientation. */
	glRotatef(25, 1.0, 0.0, 0.0);

	angle_x=-30.0f;
	angle_y=0.0f;

	//Call glut main loop
    glutMainLoop();

    return 0;             /* ANSI C requires main to return int. */
}
Ok, answered my own question. Problem was down to file access differences between Release and Debug....thought it was going to be more sinister than that!
Topic archived. No new replies allowed.