-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
289 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
int ADD_twoOperands(int op1, int op2) { | ||
return op1 + op2; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
int ADD_twoOperands(int, int); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
int SUB_twoOperands(int op1, int op2) { | ||
return op1 - op2; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
int SUB_twoOperands(int, int); |