diff --git a/main/main.cpp b/main/main.cpp index fdf836c..1bef42a 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -28,6 +28,8 @@ int main(int argc, char** argv) std::cout << "OUTPUT ------------------------ OUTPUT\n" << std::endl; //Memory that is used now //outprint of all memory + } else if (eingabe != "exit"){ + std::cout << eingabe << " <- is not a known command" << std::endl; } } return 0; diff --git a/src/SharedMemory.cpp b/src/SharedMemory.cpp index 77520f6..ff81723 100644 --- a/src/SharedMemory.cpp +++ b/src/SharedMemory.cpp @@ -1,14 +1,20 @@ #include #include "SharedMemory.h" #include +#include key_t changedKey() { + std::ofstream keyFile; + keyFile.open("key.log", std::ofstream::out | std::ofstream::trunc); + keyFile.clear(); int newKey; std::cout << "Type in a new Key for the Shared Memory Segment" << std::endl; std::cout << "new Key#"; std::cin >> newKey; std::cout <<"New Key is -> " << newKey << std::endl; + keyFile << newKey; + keyFile.close(); return key_t(newKey); } @@ -36,9 +42,7 @@ void initSharedMemory(void) { std::string answer = getAnswerFromUser(); if(answer.compare("y") == 0) { - std::cout << "Please type in a new Key:\n"; - std::cout << "#"; - std::cin >> impl.sharedMemoryKey; + impl.sharedMemoryKey = changedKey(); std::cout << "new Try with Key:c " << impl.sharedMemoryKey << std::endl; initSharedMemory(); } else if(answer.compare("n") == 0) { diff --git a/src/SharedMemory.h b/src/SharedMemory.h index 96aefca..344aacc 100644 --- a/src/SharedMemory.h +++ b/src/SharedMemory.h @@ -12,4 +12,6 @@ void deleteSharedMemory(int s); void deleteSharedMemory(void); void initSharedMemory(void); +key_t changedKey(); +std::string getAnswerFromUser(); #endif //SHARED_MEMORY_H diff --git a/src/key.log b/src/key.log new file mode 100644 index 0000000..bd41cba --- /dev/null +++ b/src/key.log @@ -0,0 +1 @@ +12345 \ No newline at end of file