started puzzle 1 again in c

This commit is contained in:
Seth Samuel 2024-12-02 15:52:44 +13:00
parent 31b1c51bf5
commit 5a1721acf7
5 changed files with 7 additions and 108 deletions

39
.vscode/launch.json vendored
View file

@ -1,39 +0,0 @@
{
"configurations": [
{
"type": "cmake",
"request": "launch",
"name": "Debug portfile(s)",
"cmakeDebugType": "external",
"pipeName": "/tmp/vcpkg_ext_portfile_dbg",
"preLaunchTask": "Debug vcpkg commands"
},
{
"name": "C/C++: g++ build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++ build active file",
"miDebuggerPath": "/usr/bin/gdb"
}
],
"version": "2.0.0"
}

13
.vscode/settings.json vendored
View file

@ -1,13 +0,0 @@
{
"vcpkg.target.defaultTriplet": "x64-linux",
"vcpkg.target.hostTriplet": "x64-linux",
"vcpkg.target.useManifest": false,
"vcpkg.target.useStaticLib": false,
"cmake.configureArgs": [
"-DVCPKG_MANIFEST_MODE=OFF",
"-DVCPKG_TARGET_TRIPLET=x64-linux"
],
"files.associations": {
"string.h": "c"
}
}

26
.vscode/tasks.json vendored
View file

@ -3,10 +3,8 @@
{ {
"type": "cppbuild", "type": "cppbuild",
"label": "C/C++: gcc build active file", "label": "C/C++: gcc build active file",
"command": "/usr/bin/g++", "command": "/usr/bin/gcc",
"args": [ "args": [
"--std",
"gnu++23",
"-fdiagnostics-color=always", "-fdiagnostics-color=always",
"-g", "-g",
"${file}", "${file}",
@ -24,28 +22,6 @@
"isDefault": true "isDefault": true
}, },
"detail": "Task generated by Debugger." "detail": "Task generated by Debugger."
},
{
"type": "cppbuild",
"label": "C/C++: g++ build active file",
"command": "/usr/bin/g++",
"args": [
"--std",
"gnu++23",
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "Task generated by Debugger."
} }
], ],
"version": "2.0.0" "version": "2.0.0"

BIN
1/puzzle1

Binary file not shown.

View file

@ -1,40 +1,15 @@
#include <stdbool.h> #include <stdbool.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#define stringSize 20
int listSize = 0; FILE *puzzleFile;
char readChar = '0';
char stringOne[stringSize];
char stringTwo[stringSize];
int readIntoList(char *stringList) {
int index = 0;
while (1) {
char next = getchar();
if (next == '.') {
break;
} else if (next != '\n') {
stringList[index] = next;
index++;
}
}
}
int main() { int main() {
printf("enter list size: \n");
scanf("%i", &listSize); puzzleFile = fopen("input.txt", "r");
int listOne[listSize]; if (puzzleFile==NULL){
int listTwo[listSize]; printf("file unable to be opened");
}
memset(listOne, '\0', listSize); printf("helloworld");
memset(listTwo, '\0', listSize);
printf("enter list 1: \n");
readIntoList(stringOne);
printf("enter list 2: \n");
readIntoList(stringTwo);
printf("one: %s \ntwo: %s ", stringOne, stringTwo);
} }