Hey there, ill start off by saying im quite fresh with C, but im trying
I'm having a problem with some code here:
Code:
/* Program: Course Project - CD Inventory
* Version: 1.0
* Author: Joe
*
* This program is used to track its inventory of CD's
*
* Version 1.0
* - Only Reads input from user, and displays input
* - Only Reads in Title/Artist/Number of Tracks/(Album or Single)/Price
* - Does not save user input once program has finished
* - Only stores infomation about ONE CD
*/
#include <stdio.h>
#include <string.h> // string library to access string functions
int main(void)
{
char Title[101]; // Store track Title, extra 1 for NULL char
char Artist[101]; // Store Artist Name, extra 1 for NULL char
short nTracks; // Store No. of Tracks
short Album; // Store Album/Singles as int
char type; // For figuring out Albulm or single
float Price; // Store price as double to store cents as well
printf("\n******** CD Inventory v 1.0 ********\n");
/* The title */
printf("Please enter the Title of the CD: ");
scanf("%s", Title);
/* The artist */
printf("Please enter the Artist: ");
scanf("%s", Artist);
/* The tracks */
printf("Please enter the Number of tracks on the CD: ");
scanf("%d", &nTracks);
/* The Price */
printf("Please enter the Price of the CD: $ ");
scanf("%f", &Price);
/* Album or Single */
printf("Album or Single? Type a for album or s for single: ");
scanf("%c", &type);
Album = type == 'a';
/* Output of CD details */
printf("\n========== CD Details =========\n");
printf("Title: %s\n", Title);
printf("Artist: %s\n", Artist);
printf("Tracks: %d\n", nTracks);
printf("Price: $%.2f\n", Price);
if(Album)
printf("Album\n");
else
printf("Single\n");
getchar();
return 0;
}
Problem being that after the program asks for the price of the CD, it skips the code:
Code:
/* Album or Single */
printf("Album or Single? Type a for albulm or s for single: ");
scanf("%c", &type);
Album = type == 'a';
And i have no idea why, it's driving me crazy, help MUCH appreciated!