#include <cstddef> // std::size_t
#include <cstring> // std::strcpy()
#include <string> // std::string, std::getline()
#include <iostream> // std::cin, std::cout
int main()
{
constexpr std::size_t whole_input_size { 820 }; // 820 bytes =~ 0.8 * 1024 bytes + 1 for terminating zero
char whole_input[whole_input_size] {};
std::size_t whole_input_length {};
char const * const word_to_find { "Tastatur" };
for (std::string line; whole_input_length < whole_input_size - 1 && std::getline(std::cin, line) && line.length();) {
// append line to whole_input buffer:
line += "\r\n";
std::size_t whole_input_space_left = whole_input_size - 1 - whole_input_length;
std::size_t num_chars_to_copy = line.length() <= whole_input_space_left ? line.length() : whole_input_space_left;
std::strncpy(whole_input + whole_input_length, line.c_str(), num_chars_to_copy);
whole_input_length += num_chars_to_copy;
// find word_to_find:
if (line.find(word_to_find) != std::string::npos) {
std::cout << '"' << word_to_find << "\" found in the last line entered :)\n\n";
break;
}
}
// output whole_input:
std::cout << "Your input:\n" << whole_input << '\n';
}
Aber es ist wieder einmal eine ziemlich sinnfreie Aufgabe die ausdrücklich nicht wirklich schönes C++ und künstliche Beschränkungen fordert. Bitte besorg' Dir - falls Du nicht nur durch diese Vorlesung irgendwie durchkommen willst sondern wirklich was lernen willst - ein gutestm Lehrbuch. Threads über Bücher zu C++ findest Du hier im Forum zur Genüge.