A
arnuld
there is no "compile-time error". after i enter input and hit ENTER i
get a run-time error. here is the code:
---------- PROGRAMME --------------
/* Stroustrup, 5.9, exercise
11
STATEMENT:
Read a sequence of words from the input. use "quit" as the
word
to terminate the input. Print the words in the order they
were
entered. don't print a word twice.modify the programme to sort
the
words before printing
them.
*/
#include<iostream>
#include<string>
int main()
{
const std::string EOI = "quit"; // End Of
Input
char* user_input = "";
const int max_input = 1000;
char* collect_input[max_input + 1];
for(int i=0; user_input != EOI || i < max_input; ++i)
{
std::cin >> user_input;
collect_input = user_input;
}
return 0;
}
------------- OUTPUT -------------
[arch@voodo tc++pl]$ g++ 5.9_ex-11.cpp
[arch@voodo tc++pl]$ ./a.out
like
Segmentation fault
[arch@voodo tc++pl]$
get a run-time error. here is the code:
---------- PROGRAMME --------------
/* Stroustrup, 5.9, exercise
11
STATEMENT:
Read a sequence of words from the input. use "quit" as the
word
to terminate the input. Print the words in the order they
were
entered. don't print a word twice.modify the programme to sort
the
words before printing
them.
*/
#include<iostream>
#include<string>
int main()
{
const std::string EOI = "quit"; // End Of
Input
char* user_input = "";
const int max_input = 1000;
char* collect_input[max_input + 1];
for(int i=0; user_input != EOI || i < max_input; ++i)
{
std::cin >> user_input;
collect_input = user_input;
}
return 0;
}
------------- OUTPUT -------------
[arch@voodo tc++pl]$ g++ 5.9_ex-11.cpp
[arch@voodo tc++pl]$ ./a.out
like
Segmentation fault
[arch@voodo tc++pl]$