diff --git a/c/pipes3/.vscode/tasks.json b/c/pipes3/.vscode/tasks.json deleted file mode 100644 index 08d9005..0000000 --- a/c/pipes3/.vscode/tasks.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "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" -} \ No newline at end of file diff --git a/c/pipes3/a.out b/c/pipes3/a.out deleted file mode 100755 index 3d1eda8..0000000 Binary files a/c/pipes3/a.out and /dev/null differ diff --git a/c/pipes3/main b/c/pipes3/main deleted file mode 100755 index 93307eb..0000000 Binary files a/c/pipes3/main and /dev/null differ diff --git a/c/pipes3/programa b/c/pipes3/programa index 3d1eda8..c7cf611 100755 Binary files a/c/pipes3/programa and b/c/pipes3/programa differ diff --git a/c/pipes4/main.c b/c/pipes4/main.c new file mode 100644 index 0000000..db6515c --- /dev/null +++ b/c/pipes4/main.c @@ -0,0 +1,32 @@ +#include + +void clear_buffer(void); + +int main(void) { + int edad = 0; + char buffer[20]; + + printf("Ingresar una edad:"); + scanf("%d", &edad); + + clear_buffer(); + + printf("\nIngresar un nombre:"); + + fgets(buffer, 20, stdin); + + printf("\n====================================\n"); + printf("La edad ingresada es: %d \n", edad); + + printf("El nombre ingresado es: %s \n", buffer); + + return 0; +} + +void clear_buffer(void) { + + int c = 0; + + while ((c = getchar()) && c != '\n' && c != EOF) { + } +} diff --git a/c/pipes4/programa b/c/pipes4/programa new file mode 100755 index 0000000..6fdb4a0 Binary files /dev/null and b/c/pipes4/programa differ diff --git a/c/pipes5/main.c b/c/pipes5/main.c new file mode 100644 index 0000000..2097005 --- /dev/null +++ b/c/pipes5/main.c @@ -0,0 +1,50 @@ +#include + +typedef struct Document { + int id; + char active; + char name[50]; +} Document; + +void leer_id(Document *); +void leer_nombre(Document *); +void imprimir(Document *); + +int main(void) { + + Document hdr; + + leer_id(&hdr); + leer_nombre(&hdr); + imprimir(&hdr); + + return 0; +} + +void leer_id(Document *ref) { + int rid = -1; + char c; + char ractive = 'n'; + printf("Entrada:"); + scanf("%d", &rid); + ref->id = rid; + while ((c = getchar()) && c != '\n' && c != EOF) { + if ((c == 's') || (c == 'S')) { + ractive = 's'; + } + } + ref->active = ractive; + printf("\n"); +} + +void leer_nombre(Document *ref) { + printf("Nombre:"); + fgets(ref->name, 50, stdin); +} + +void imprimir(Document *ref) { + printf("=======================================\n"); + printf("ID: %d \n", ref->id); + printf("ACTIVE: %c \n", ref->active); + printf("NOMBRE: %s \n", ref->name); +} diff --git a/c/pipes5/programa b/c/pipes5/programa new file mode 100755 index 0000000..b65ce05 Binary files /dev/null and b/c/pipes5/programa differ