From 0fc98cc661b8dba35dfecf8f2203ab0f8560a7ad Mon Sep 17 00:00:00 2001 From: Johannes Theiner Date: Thu, 1 Nov 2018 20:39:19 +0100 Subject: [PATCH] =?UTF-8?q?a3:=20Grundger=C3=BCst?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 4 ++++ CMakeLists.txt | 11 +++++++++++ src/c/CMakeLists.txt | 1 + src/c/a3.c | 30 ++++++++++++++++++++++++++++++ src/c/a3.h | 2 ++ 5 files changed, 48 insertions(+) create mode 100644 .gitignore create mode 100644 CMakeLists.txt create mode 100644 src/c/CMakeLists.txt create mode 100644 src/c/a3.c create mode 100644 src/c/a3.h diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..20fba2b --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +# Created by .ignore support plugin (hsz.mobi) +.idea +bin +cmake-build-debug diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..ce38bb3 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.3) +project(Hardwarenahe_Programmierung) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c14") +SET(CMAKE_BUILD_TYPE Debug) + +# These are the corresponding output paths +set (EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin) +set (LIBRARY_OUTPUT_PATH ${EXECUTABLE_OUTPUT_PATH}) + +add_subdirectory(src/c) \ No newline at end of file diff --git a/src/c/CMakeLists.txt b/src/c/CMakeLists.txt new file mode 100644 index 0000000..84164e2 --- /dev/null +++ b/src/c/CMakeLists.txt @@ -0,0 +1 @@ +add_executable(a3 a3.c) \ No newline at end of file diff --git a/src/c/a3.c b/src/c/a3.c new file mode 100644 index 0000000..a61f18f --- /dev/null +++ b/src/c/a3.c @@ -0,0 +1,30 @@ +#include "a3.h" +#include +#include + +void memdump(unsigned char *string) { + +} + + +int memreplace(char *string, char cin, char cout, char **caddr) { + +} + +int main(int argc, char **argv) { + if(argc <= 3) { + printf("Not enough arguments"); + return -1; + } + + + memdump((unsigned char*)argv[1]); + char **lastAddress; + int count = memreplace(argv[1], *argv[2], *argv[3], 0); + + printf("Laenge der Zeichenkette (inkl \\0): %i Bytes\n", sizeof(argv[1])); + printf("Ersetzen: '%c' mit '%c'\n", *argv[2], *argv[3]); + printf("Suchzeichen wurde %i mal gefunden und ersetzt\n", count); + printf("zuletzt an Addresse 0x%lx \n", (unsigned long) (&lastAddress)); + memdump((unsigned char*)argv[1]); +} \ No newline at end of file diff --git a/src/c/a3.h b/src/c/a3.h new file mode 100644 index 0000000..5752e0e --- /dev/null +++ b/src/c/a3.h @@ -0,0 +1,2 @@ +void mempdump(unsigned char *string); +int memreplace(char *string, char cin, char cout, char **caddr); \ No newline at end of file