Hi. I'm new to C, so I have probably made an elementary mistake in my code.
I am trying to make a program for finding roots of a quadratic equation, using if and else, but first I'm trying to get used to using the sscanf function which I have never encountered before. After compiling I am getting an error in line 12: parse error before string constant

Can anybody shed some light on this for me please?

Heres my program:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int a, b, c;
float real_root;

int main (int argc, char* argv[])
	printf ("Enter the co-efficients a, b, and c : ");
	sscanf (argv[1] "%d %d %d", &a, &b, &c);
	real_root = (b*b)+4*a*c;
	if (real_root < 0)
		printf("No Real Roots\n");
		return (0);

That particular one is a simple coma been missing. sscanf (argv[1], "%d %d %d", &a, &b, &c); Did you forget to return in main?

[Edit:] By the way argv[1] should be replaced by another variable place holder if you intend to ask the user for some input and after you read that input you use sscanf() for parsing it.
argv[1] is input from the command line at the start of the program.

This article has been dead for over six months. Start a new discussion instead.