practica pipes3-5
This commit is contained in:
Vendored
-28
@@ -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"
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -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) {
|
||||
}
|
||||
}
|
||||
Executable
BIN
Binary file not shown.
@@ -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);
|
||||
}
|
||||
Executable
BIN
Binary file not shown.
Reference in New Issue
Block a user