Originally Posted by
Salem
> even i tried gcc -o main.c add.c
Nice, you just trashed your source file with a mis-guided -o option.
> When I ran the command gcc main.c add.c I received an error message
Right, and I'm supposed to believe you managed to read my post and create the 4 necessary files?
I apologize for the confusion and the errors I encountered. Thank you for your patience
I use the following commands to compile and run the main code:
gcc -o main main.c add.c
main
I use the following commands to compile and run the test code:
gcc -o add_test add_test.c add.c
add_test
After running the tests, I check if there are any error messages. If there are none, it indicates that the tests passed successfully.
To intentionally introduce an error into the code provided, I modify the ADD() function in add.c to return an incorrect result.
Code:
// add.c
#include "add.h"
int ADD ( int x, int y)
{
int r = x - y;
return r;
}
I got result Test ADD() failed: Incorrect result when i compile and ran code