...
기 string include 고 char * 고 #1,#2,#3 strcpy 고고 ,
"empty" 기 거 PUSH , 값 개 값 경 ... 그 고 ..
"empty" 기 거 PUSH , 값 개 값 경 ... 그 고 ..
AnswerMe .#1, #2, #3 게 꾸 겠. 그고 .
~cpp #1 : strcpy(array[i], "empty"); #2 : strcpy(array[0], "empty"); #3 : strcpy(array[tail], "empty");, . 금 각, . --NeoCoin
. --;;
~cpp
#include <iostream>
#include <string>
using namespace std;
const int ASIZE = 5;
// VC++ 7.0 결과, 그 .
// VC++ 6.0 , release .
void main()
{
std::string a;
char * array[ASIZE]; // Pointer . , 공간 .
// char 32bit 값 Pointer 5개
// .
// 각 Pointer 값 .( )
int tail = 0, status = 3;
int select, count;
for(int i = 0 ; i < ASIZE ; i++)
strcpy(array[i], "empty"); // Pointer 근 공간
// . VC++ 6.0 Debug 그
// 근 공간 기
// . 경 debug
// 기값 . Release 꾸 .
do
{
cout << "1. PUSH 2. Pop 3. Stack 4. Queue 5. Show 6. Exit" << endl;
cin >> select;
switch(select)
{
case 1 :
cout << " : ";
if (tail == ASIZE)
{
cout << " ." << endl;
break;
}
cin >> array[tail]; // array[tail] 까
// Pointer. 그
// . 근 ,
// .
tail++;
break;
case 2 :
if(status == 4) //
{
strcpy(array[0], "empty");
tail--;
for(count = 0 ; count < tail ; count++)
array[count] = array[count+1]; // string 경 , Pointer 값 .
// string , call by value class간
// . 계 값
// . char 결국 곳 게 .
// 그 곳 꾸 .
}
else //
{
tail--;
strcpy(array[tail], "empty"); // , .
}
break;
case 3 :
status = 3;
break;
case 4 :
status = 4;
break;
case 5 :
for(count = 0 ; count < tail ; count++)
{
cout << array[count] << "] "; // , Pointer
// . , empty+null 값
// 기 , 값 .
}
cout << endl;
break;
case 6 :
break;
default :
cout << " 1 6까 " << endl;
}
}while(select != 6);
}
, cin
~cpp std:string 과, char* cin string
string 과 .
~cpp C:\Program Files\Microsoft Visual Studio\VC98\Include\istream . 궁금, Debug .string 과 .
~cpp string element; cin >> element>> , string 금 , 과 . .
~cpp
... ...
if (_Ok) // ? 기 enter, space 기
{ // state okay, extract characters
......
_Str.erase(); // string 공간 기 element
_TRY_IO_BEGIN //
/// 길 고, 공간
_Mysizt _Size = 0 < _Istr.width()
&& (_Mysizt)_Istr.width() < _Str.max_size()
? (_Mysizt)_Istr.width() : _Str.max_size();
......
/// , string
for (; 0 < _Size; --_Size, _Meta = _Istr.rdbuf()->snextc())
......
_Str.append(1, _Traits::to_char_type(_Meta)); // . , string 객
// .
......
그, 과 ~cpp char* element; cin >> element;값 과 . 거 과 거.
~cpp
......
*_Str++ = _Traits::to_char_type(_Meta); // _Str char* element . , 공간 .
// 그, element 곳 값 고 .
// 그공간 OS 그 근 ,
// 그 .
......
~cpp
#include <iostream>
#include <string>
using namespace std;
const int ASIZE = 5;
void main()
{
string array[ASIZE];
int tail = 0, status = 3;
int select, count;
for(int i = 0 ; i < ASIZE ; i++)
array[i] = "empty"; //#1
do
{
cout << "1. PUSH 2. Pop 3. Stack 4. Queue 5. Show 6. Exit" << endl;
cin >> select;
switch(select)
{
case 1 :
cout << " : ";
if (tail == ASIZE)
{
cout << " ." << endl;
break;
}
cin >> array[tail];
tail++;
break;
case 2 :
if(status == 4) //
{
array[0] = "empty"; //#2
tail--;
for(count = 0 ; count < tail ; count++)
array[count] = array[count+1];
}
else //
{
tail--;
array[tail] = "empty"; //#3
}
break;
case 3 :
status = 3;
break;
case 4 :
status = 4;
break;
case 5 :
for(count = 0 ; count < tail ; count++)
{
cout << array[count] << "]\t";
}
cout << endl;
break;
case 6 :
break;
default :
cout << " 1 6까 " << endl;
}
}while(select != 6);
}










