practica pipes3-5

This commit is contained in:
2026-11-03 15:00:09 -03:00
parent f4f56db493
commit 82008f51bf
8 changed files with 82 additions and 28 deletions
-28
View File
@@ -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"
}
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+32
View File
@@ -0,0 +1,32 @@
#include <stdio.h>
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) {
}
}
BIN
View File
Binary file not shown.
+50
View File
@@ -0,0 +1,50 @@
#include <stdio.h>
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);
}
BIN
View File
Binary file not shown.