änderungen für den memoryaccess key Cigerxwin Chaker

This commit is contained in:
cigerxwinchaker 2019-11-12 17:26:21 +01:00
parent 121ae391c0
commit 0c24818614
4 changed files with 12 additions and 3 deletions

View File

@ -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;

View File

@ -1,14 +1,20 @@
#include <cstdlib>
#include "SharedMemory.h"
#include <iostream>
#include <fstream>
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) {

View File

@ -12,4 +12,6 @@
void deleteSharedMemory(int s);
void deleteSharedMemory(void);
void initSharedMemory(void);
key_t changedKey();
std::string getAnswerFromUser();
#endif //SHARED_MEMORY_H

1
src/key.log Normal file
View File

@ -0,0 +1 @@
12345