31.10.2013, 23:36. Просмотров 350. Ответов 4
При выполнении условия не выходит из цикла а продолжается и выходит за границы
C++ |
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
| #include <iostream>
#include <conio.h>
#include <windows.h>
using namespace std;
void main()
{
char choice;
char temp[128];
const DWORD dwBuferLenght = 128;
TCHAR tcCurrentDir[128]= { NULL };
if(!GetCurrentDirectory(dwBuferLenght,tcCurrentDir)) cout<<"Error";
CharToOem(tcCurrentDir,temp);
cout<<temp<<endl;
cin>>choice;
if(choice == 'u')
{
int i = dwBuferLenght;
while(temp[i] != '/')
{
temp[i] = NULL;
i--;
}
cout<<temp;
}
getch();
} |
|