Beginner - Program is crashing

Hi all,

(using visual basic)
Really new to C++ and i keep getting the following error :

"A problem caused the program to stop working correctly. Windows will close the program and notify you if a solution is available"

So far when I have an error im able to determine where from the specific line called out, however in this case not so.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
  /*
* Determines the value of a colletion of coins.
*/
#include <stdio.h>
int
main(void)
{
	char first, middle, last; /* input - 3 initials */	
	int pennies, nickels;     /* input - count of each coin type*/
	int dimes, quarters;      /* input - count of each coin type*/
	int dollars;              /* input - count of each coin type*/
	int change;                /* output - change amount*/
	int total_dollars;          /*output - dollar amount*/
	int total_cents;           /* total cents*/

	/* Get and display the customer's initials.*/

	printf("Type in your 3 initials and press return>");
		scanf("%c%c%c", &first, &middle, &last);
		printf("\n%c%c%c, please enter your coin information.\n",
			first, middle, last);

    /* Get the count of each kind of coin.*/
		printf("Number of $ coins > ");
		scanf("%d", &dollars);
		printf("Number of quarters> ");
		scanf("%d", &quarters);
		printf("Number of dimes > ");
		scanf("%d", &dimes);
		printf("Number of nickels > ");
		scanf("%d, &nickels");
		printf("Numbe of pennies >");
		scanf("%d", &pennies);

		/* Compute the total value in cents.*/
		total_cents = 100 * dollars + 25 * quarters + 10 * dimes +
			5 * nickels + pennies;

		/* Find the value in dollars and change*/	
		total_dollars = total_cents / 100;
		change = total_cents % 100;

		/* Display the credit slip with value in dollars and change.*/

		printf("\n\n%c%c%c Coin Credit\nDollars: %d\nChange: %d cents\n",
			first, middle, last, total_dollars, change);


		return (0);
}




Thanks yall
scanf("%d, &nickels");

Take a good look at that line.


Then, learn about C++ input/output : http://www.cplusplus.com/doc/tutorial/basic_io/
Topic archived. No new replies allowed.