Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem opening files based on position...

Status
Not open for further replies.

Aven

Programmer
Jun 8, 2000
3
0
0
US
I have a program that is supposed to open a file based on the coordinate on an x, y, and z coordinate.&nbsp;&nbsp;It then gets information about that coordinate and outputs it.&nbsp;&nbsp;But for some reason it does not work correctly.. So I took away the Z axis to make it easier to work with, and then I deformed some of the code to try to find the bug, but i cannot.&nbsp;&nbsp;Maybe someone could help me if they looked at it, so here is the defective code... Please help&nbsp;&nbsp;:<br><br><br>do<br>{<br>acc = 1;<br>cin &gt;&gt; dir;<br>strcpy(town, &quot;Cador&quot;);<br>strcpy(dirtest, &quot;n&quot;);<br>strcpy(dirtest1, &quot;ne&quot;);<br>strcpy(dirtest2, &quot;e&quot;);<br>strcpy(dirtest3, &quot;se&quot;);<br>strcpy(dirtest4, &quot;s&quot;);<br>strcpy(dirtest5, &quot;sw&quot;);<br>strcpy(dirtest6, &quot;w&quot;);<br>strcpy(dirtest7, &quot;nw&quot;);<br>strcpy(dirtest8, &quot;d&quot;);<br>strcpy(dirtest9, &quot;u&quot;);<br>if (strcmpi(dir, dirtest) == 1)<br>{<br>y++;<br>y1 = 1;<br>}<br>else if (strcmpi(dir, dirtest1) == 1)<br>{<br>y++;<br>y1 = 1;<br>x++;<br>x1 = 1;<br>}<br>else if (strcmpi(dir, dirtest2) == 1)<br>{<br>x++;<br>x1 = 1;<br>}<br>else if (strcmpi(dir, dirtest3) == 1)<br>{<br>y--;<br>y1 = -1;<br>x++;<br>x1 = 1;<br>}<br>else if (strcmpi(dir, dirtest4) == 1)<br>{<br>y--;<br>y1 = -1;<br>}<br>else if (strcmpi(dir, dirtest5) == 1)<br>{<br>y--;<br>y1 = -1;<br>x--;<br>y1 = -1;<br>}<br>else if (strcmpi(dir, dirtest6) == 1)<br>{<br>x--;<br>x1 = -1;<br>}<br>else if (strcmpi(dir, dirtest7) == 1)<br>{<br>y++;<br>y1 = 1;<br>x--;<br>x1 = -1;<br>}<br>else if (strcmpi(dir, dirtest8) == 1)<br>{<br>z--;<br>}<br>else if (strcmpi(dir, dirtest9) == 1)<br>{<br>z++;<br>}<br>else<br>{<br>acc = 0;<br>}<br>do {<br>if (acc == 0)<br>{<br>break;<br>}<br>strcpy(town, &quot;Cador&quot;);<br>if(x &lt; 10 )<br>{<br>strcat(town, &quot;00&quot;);<br>}<br>else if(x &gt; 9 && x &lt; 100)<br>{<br>strcat(town, &quot;0&quot;);<br>}<br>sprintf(town1, &quot;%d&quot;, x);<br>strcat(town, town1);<br>if(y &lt; 10 )<br>{<br>strcat(town, &quot;00&quot;);<br>}<br>else if(y &gt; 9 && y &lt; 100)<br>{<br>strcat(town, &quot;0&quot;);<br>}<br>sprintf(town2, &quot;%d&quot;, y);<br>strcat(town, town2);<br><br>strcat(town, &quot;000&quot;);<br>// sprintf(town3, &quot;%d&quot;, z);<br>// strcat(town, town3);<br>strcat(town, &quot;.dat&quot;);<br>ifstream infile(town);<br><br><br>acc = 1;<br>infile &gt;&gt; roomdesc;<br>cout &lt;&lt; roomdesc &lt;&lt; endl;<br>infile.close();<br>}<br>while (strcmpi(dir, &quot;exit&quot;) != 1);<br>}<br>while (strcmpi(dir, &quot;exit&quot;) != 1);
 
&nbsp;&nbsp;&nbsp;&nbsp;What exactly is it not doing right?<br> <p>James P. Cottingham<br><a href=mailto: > </a><br><a href= Veneer Co., Inc.</a><br>All opinions are mine alone and do not necessarily reflect those of my employer.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top