LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   gcc, segmentation fault error (https://www.linuxquestions.org/questions/linux-general-1/gcc-segmentation-fault-error-4175438526/)

curious95 11-24-2012 04:18 AM

gcc, segmentation fault error
 
1 Attachment(s)
When i try to run the binary of the source code attatched i get this error
Code:

Enter Item number: 12
Enter Unit price: 12
Enter Purchase date (mm/dd/yyyy) : 12/12/1222
Segmentation fault (core dumped)

I get this error no matter what input i give.

linosaurusroot 11-24-2012 04:32 AM

forgotten & signs in scanf

millgates 11-24-2012 04:33 AM

Your forgetting to reference the variables in scanf. Also, if you want input (or output) with slashes, your FORMAT string should reflect that:

Code:

scanf("%d/%d/%d", &month, &day, &year);

curious95 11-24-2012 04:41 AM

I can't believe i forgot that :( thanks :)


All times are GMT -5. The time now is 09:14 AM.