Skip to content

Commit

Permalink
Subida de archivos ejemplo
Browse files Browse the repository at this point in the history
  • Loading branch information
lescobars committed Oct 12, 2024
1 parent c30d12e commit 575c8bf
Show file tree
Hide file tree
Showing 11 changed files with 289 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"configurations": [
{
"name": "windows-gcc-x86",
"includePath": [
"${workspaceFolder}/**"
],
"compilerPath": "C:/MinGW/bin/gcc.exe",
"cStandard": "${default}",
"cppStandard": "${default}",
"intelliSenseMode": "windows-gcc-x86",
"compilerArgs": [
""
]
}
],
"version": 4
}
24 changes: 24 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "C/C++ Runner: Debug Session",
"type": "cppdbg",
"request": "launch",
"args": [],
"stopAtEntry": false,
"externalConsole": true,
"cwd": "c:/Users/jazna/Desktop/Proyectobot/prog1/Exemple estructura projecte-20241011",
"program": "c:/Users/jazna/Desktop/Proyectobot/prog1/Exemple estructura projecte-20241011/build/Debug/outDebug",
"MIMode": "gdb",
"miDebuggerPath": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
59 changes: 59 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"C_Cpp_Runner.cCompilerPath": "gcc",
"C_Cpp_Runner.cppCompilerPath": "g++",
"C_Cpp_Runner.debuggerPath": "gdb",
"C_Cpp_Runner.cStandard": "",
"C_Cpp_Runner.cppStandard": "",
"C_Cpp_Runner.msvcBatchPath": "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/Build/vcvarsall.bat",
"C_Cpp_Runner.useMsvc": false,
"C_Cpp_Runner.warnings": [
"-Wall",
"-Wextra",
"-Wpedantic",
"-Wshadow",
"-Wformat=2",
"-Wcast-align",
"-Wconversion",
"-Wsign-conversion",
"-Wnull-dereference"
],
"C_Cpp_Runner.msvcWarnings": [
"/W4",
"/permissive-",
"/w14242",
"/w14287",
"/w14296",
"/w14311",
"/w14826",
"/w44062",
"/w44242",
"/w14905",
"/w14906",
"/w14263",
"/w44265",
"/w14928"
],
"C_Cpp_Runner.enableWarnings": true,
"C_Cpp_Runner.warningsAsError": false,
"C_Cpp_Runner.compilerArgs": [],
"C_Cpp_Runner.linkerArgs": [],
"C_Cpp_Runner.includePaths": [],
"C_Cpp_Runner.includeSearch": [
"*",
"**/*"
],
"C_Cpp_Runner.excludeSearch": [
"**/build",
"**/build/**",
"**/.*",
"**/.*/**",
"**/.vscode",
"**/.vscode/**"
],
"C_Cpp_Runner.useAddressSanitizer": false,
"C_Cpp_Runner.useUndefinedSanitizer": false,
"C_Cpp_Runner.useLeakSanitizer": false,
"C_Cpp_Runner.showCompilationTime": false,
"C_Cpp_Runner.useLinkTimeOptimization": false,
"C_Cpp_Runner.msvcSecureNoWarnings": false
}
12 changes: 12 additions & 0 deletions .vscode/sftp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "My Server",
"host": "matagalls.salle.url.edu",
"protocol": "sftp",
"port": 22,
"username": "luis.escobar",
"password": "Esc.b@r23",
"remotePath": "/users/home/luis.escobar/ProYectosProg2024/FicheroPrueba11102024",
"uploadOnSave": true,
"useTempFile": false,
"openSsh": false
}
66 changes: 66 additions & 0 deletions TEST_main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/**
* The purpose of this file is to contain all the tests done to check that
* the program is working correctly. If desired, tests could be distributed
* between different .c files.
**/

#include <stdio.h>
#include "add.h"
#include "sub.h"

/*
* The goal of this test is to check if when two positive integer
* operands are given, the progrm is able to add them correctly;
*/
void TEST_shouldAddAndPrint5() {
int op1, op2;
int result = 0;

op1 = 2;
op2 = 3;

result = ADD_twoOperands(op1, op2);
printf("TEST - Result in shouldAddAndPrint5 is: %d\n", result);
}

/*
* The goal of this test is to check if when a positive integer
* operand and a negative operand are given, the progrm is able to
* add them correctly;
*/
void TEST_shouldAddAndPrint4() {
int op1, op2;
int result = 0;

op1 = 5;
op2 = -1;

result = ADD_twoOperands(op1, op2);
printf("TEST - Result in shouldAddAndPrint4 is: %d\n", result);
}

/*
* This test will check that two positive integers can be subtracted
*/
void TEST_shouldSubAndPrint1() {
int op1, op2;
int result = 0;

op1 = 15;
op2 = 14;

result = SUB_twoOperands(op1, op2);
printf("TEST - Result in shouldSubAndPrint1 is: %d\n", result);

}


int main() {
// Let's try a variety of functionalities
TEST_shouldAddAndPrint5();
TEST_shouldAddAndPrint4();
TEST_shouldSubAndPrint1();
// More tests could be added

return 0;
}
4 changes: 4 additions & 0 deletions add.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
int ADD_twoOperands(int op1, int op2) {
return op1 + op2;
}

1 change: 1 addition & 0 deletions add.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
int ADD_twoOperands(int, int);
85 changes: 85 additions & 0 deletions main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#include <stdio.h>
#include "add.h"
#include "sub.h"

#define ADD 1
#define SUB 2
#define EXIT 3

int printMenu() {
int option = 0;

printf("Select an option:\n");
printf("\t1.Add\n");
printf("\t2.Subtract\n");
printf("\t3.Exit\n");

scanf("%d", &option);

return option;
}

void doAdd() {
int num1, num2, result;

// Let's add two numbers with our code
printf("Insert number 1: ");
scanf("%d", &num1);

printf("Insert number 2: ");
scanf("%d", &num2);

result = ADD_twoOperands(num1, num2);

printf("The result of adding these two integers is %d\n", result);
}



void doSub() {
int num1, num2, result;

// Let's subtract two numbers with our code
printf("Insert number 1: ");
scanf("%d", &num1);

printf("Insert number 2: ");
scanf("%d", &num2);

result = SUB_twoOperands(num1, num2);

printf("The result of subtracting these two integers is %d\n", result);

}

void manageOption(int option) {
if (option != ADD && option != SUB && option != EXIT) {
printf("ERROR! Insert a correct number\n");
} else {
switch (option) {
case ADD:
doAdd();
break;

case SUB:
doSub();
break;
}
}

}

int main() {
int option = 0;

printf("Welcome to the simple program! Let's do some maths\n");

do {
option = printMenu();
manageOption(option);
} while (option != EXIT);

printf("Bye!!\n");

return 0;
}
14 changes: 14 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
main.o: main.c add.h sub.h
gcc main.c -g -c

TEST_main.o: TEST_main.c add.h sub.h
gcc TEST_main.c -g -c

add.o: add.c add.h
gcc add.c -g -c

prod: main.o add.o sub.o
gcc main.o add.o sub.o -o executable

test: TEST_main.o add.o sub.o
gcc TEST_main.o add.o sub.o -g -o executable
5 changes: 5 additions & 0 deletions sub.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
int SUB_twoOperands(int op1, int op2) {
return op1 - op2;
}


1 change: 1 addition & 0 deletions sub.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
int SUB_twoOperands(int, int);

0 comments on commit 575c8bf

Please sign in to comment.