Hi everyone,

I'm reading two values from my text file after that I have to find all the possible points in this row*column data.
I wrote this code but I got an infinite loop as a result instead of getting N1=(1,1), N2(1,2) till the the last column which is n, and then it starts with the new row.

int m, n; 
        int c, r;
	file >> m;
	file >> n;

	string N;
	for (c=1; c++; c= n){
		for (r=1; r++; r= m){
			cout << "N = " << N << "( " << r << "," << c << " ) " << "\n";

Thank you!

7 Years
Discussion Span
Last Post by Mz3g

They need more than that. Actually, == is not often used in for loop tests.

for (c=1; c <= n , c++ ) {
		for (r=1; r <= n, r++ ) {

What is it you think you're doing with these statements?

   cout << "N = " << N << "( " << r << "," << c << " ) " << "\n";

Are you trying to read data from a file (m rows of n items)? Do you want N to be a string holding a set of row column coordinates, or the data at that point?


I am reading the m and n from a file and then trying to compute the whole coordinates.
well, the goal of my program is to let the user enter a random number and I'll give him all the neighbors of this number, for example,
1 2 3
4 5 6
7 8 9
if he enters 5, I have to tell him the neighbors are: 2,4,6,8 so I started with these codes but i got an infinite loop.


I'm using Xcode to test my C++ codes and my program work perfect in Microsoft Visual Studio but when I tested it in my MAC I got this "GDP: Program received signal: SIGABRT" without any output!
Can someone tell me what does this mean and how can I fix it?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.