Thread: C stops working ad 2nd scanf

  1. #1
    Registered User
    Join Date
    Aug 2017
    Posts
    21

    C stops working ad 2nd scanf

    Hi everybody
    I just can't figure out why my program stops working when i reach the second scanf
    I don't think it's a memory problem neither Windows treats it like a virus so I don't know how to figure out.
    this is the code:

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    int main(void){
        int a, b; /*addendi*/
        int c; /*somma*/
    
        printf("Somma di due numeri");
    
        printf("\nImmetti il primo numero: ");
        scanf("%d, &a");
    
        printf("\nImmetti il secondo numero: ");
        scanf("%d, &b");
    
        printf("\n");
        printf("La somma di %d e %d e':%d\n", a, b, c);
    
        return(0);
    }

  2. #2
    Registered User
    Join Date
    Aug 2017
    Posts
    21
    PS. C stops working aT* 2nd scanf

  3. #3
    Registered User
    Join Date
    Aug 2017
    Posts
    21
    *Everything ok, i solved out
    Problems with " "

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    37,968
    If you had used gcc as your compiler, it would have told you that to begin with.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Apr 2017
    Location
    Quetzaltenango
    Posts
    82
    Quote Originally Posted by Salem View Post
    If you had used gcc as your compiler, it would have told you that to begin with.
    If you were running flycheck on emacs, it would have told you when you typed it in wrong.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Program stops working when it gets to function
    By Joshino520 in forum C Programming
    Replies: 2
    Last Post: 01-19-2017, 09:00 AM
  2. Console stops working when program is running.
    By ZeroesAndOnes in forum C++ Programming
    Replies: 7
    Last Post: 08-13-2016, 02:58 PM
  3. Program suddenly stops working.
    By KittenAqua in forum C Programming
    Replies: 5
    Last Post: 10-18-2011, 05:45 AM
  4. compiler stops working
    By akkiphadnis in forum C Programming
    Replies: 2
    Last Post: 04-04-2011, 03:42 AM
  5. Program stops working as soon as I input value?..
    By darkmagic in forum C++ Programming
    Replies: 1
    Last Post: 03-08-2011, 02:18 AM

Tags for this Thread