aa-sikkkk / C-syntaxChecker

C-SyntaxChecker is a tool designed to analyze C and C++ code for common syntax issues. It checks for bracket matching, keyword usage, function definitions, and more. This tool can help developers maintain clean and error-free
GNU General Public License v3.0
2 stars 1 forks source link

Semicolons not detecting properly #2

Open oshhin opened 1 month ago

oshhin commented 1 month ago

`#include

include

int main() { int a = 5; int b = 10; printf("This is a test program.\n") if (a > b { printf("a is greater than b\n"); else { printf("a is less than or equal to b\n"); } floot c = 3.14; prntf("Value of c: %f\n", c);

for int i = 0; i < 5; i++) {
    printf("i = %d\n", i);
}

// Missing function prototype
int result = multiply(a, b);
printf("Result: %d\n", result);

// Incorrect function definition
int multiply(int x, int y) {
    return x * y;
}

// Incorrect array declaration
int arr[5 = {1, 2, 3, 4, 5};

// Incorrect pointer usage
int *p = &a;
printf("Value pointed by p: %d\n", *p);
p + 1; // This does nothing useful

// Memory allocation without proper cast
char *str = malloc(50);
strcpy(str, "Hello, World!");

// Incorrect condition in while loop
while (a < 20);
    printf("a is less than 20\n");

// Unused variables
int x, y;

// Return statement outside function
return 0;

int multiply(int x, int y) { return x * y; }

// Missing main function closing bracket`

The Code is only detecting: Line 6: Missing semicolon.

aa-sikkkk commented 1 month ago

Working on this!!!

oshhin commented 1 month ago

I too will find the ways to make it more robust, everytime as I try to change the function it only keeps on giving wrong line; honestly its frustrating