still trying to read user input
This commit is contained in:
commit
aba255affa
5 changed files with 93 additions and 0 deletions
12
.vscode/launch.json
vendored
Normal file
12
.vscode/launch.json
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"type": "cmake",
|
||||||
|
"request": "launch",
|
||||||
|
"name": "Debug portfile(s)",
|
||||||
|
"cmakeDebugType": "external",
|
||||||
|
"pipeName": "/tmp/vcpkg_ext_portfile_dbg",
|
||||||
|
"preLaunchTask": "Debug vcpkg commands"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
10
.vscode/settings.json
vendored
Normal file
10
.vscode/settings.json
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"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"
|
||||||
|
]
|
||||||
|
}
|
||||||
28
.vscode/tasks.json
vendored
Normal file
28
.vscode/tasks.json
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
{
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"type": "cppbuild",
|
||||||
|
"label": "C/C++: gcc build active file",
|
||||||
|
"command": "/usr/bin/gcc",
|
||||||
|
"args": [
|
||||||
|
"-fdiagnostics-color=always",
|
||||||
|
"-g",
|
||||||
|
"${file}",
|
||||||
|
"-o",
|
||||||
|
"${fileDirname}/${fileBasenameNoExtension}"
|
||||||
|
],
|
||||||
|
"options": {
|
||||||
|
"cwd": "${fileDirname}"
|
||||||
|
},
|
||||||
|
"problemMatcher": [
|
||||||
|
"$gcc"
|
||||||
|
],
|
||||||
|
"group": {
|
||||||
|
"kind": "build",
|
||||||
|
"isDefault": true
|
||||||
|
},
|
||||||
|
"detail": "Task generated by Debugger."
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version": "2.0.0"
|
||||||
|
}
|
||||||
BIN
puzzle1
Executable file
BIN
puzzle1
Executable file
Binary file not shown.
43
puzzle1.c
Normal file
43
puzzle1.c
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <string.h>
|
||||||
|
#define stringSize 20
|
||||||
|
|
||||||
|
int listSize = 0;
|
||||||
|
char readChar = '0';
|
||||||
|
char stringOne[stringSize];
|
||||||
|
char stringTwo[stringSize];
|
||||||
|
|
||||||
|
int readIntoList(char* stringList){
|
||||||
|
int index = 0;
|
||||||
|
|
||||||
|
while (getchar()=='\n'){
|
||||||
|
//eat up new lines in buffer
|
||||||
|
}
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
readChar = getchar();
|
||||||
|
stringList[index] = readChar;
|
||||||
|
if (readChar == '\n' || index == stringSize-1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
printf("enter list size: \n");
|
||||||
|
|
||||||
|
scanf("%i", &listSize);
|
||||||
|
int listOne[listSize];
|
||||||
|
int listTwo[listSize];
|
||||||
|
|
||||||
|
memset (listOne, '\0', listSize);
|
||||||
|
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);
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue