Thread: scanf() doesnt work

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    115

    scanf() doesnt work

    Hello

    I am trying to give some input with scanf() but it doesnt work.
    Does anyone has an idea wy? My terminal doesnt ask me to give a char.

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    
    struct album{
    	char band[20];
    	char CDtitel[50];
    	int year;
    	char songs[3][30];
    	struct album *next;
    };
    
    typedef struct album *palbum;
    
    void voegAlfToe(struct album album1, palbum *list);
    
    
    
    int main (void){
    
    	int i;
    	char inputTest;
    	char isTrue = 1, anotherAlbum;
    
    	palbum list;
    	struct album album1;
    	printf("Press a to add a album\n");
    
    	while (isTrue){
    			scanf("%c", &inputTest);
    
    		switch (inputTest){
    				case 'a' :
    
    					printf("Band\n");
    					scanf("%s", album1.band);
    					printf("CDtitel\n");
    					scanf("%s", album1.CDtitel);
    					printf("year\n");
    					scanf("%i", &album1.year);
    					printf("songs\n");
    					for (i = 0; i < 3; i++)
    						scanf("%s", album1.songs[i]);
    
    				/*	voegAlfToe(album1, &list);*/
    					isTrue = 0;
    					break;
    
    		}
    	/*	if (inputTest == 'a'){
    			printf("Do you want to add another album: press a else press any key\n");
    			scanf("%c", &anotherAlbum);
    			printf("dsfd\n");
    			if (anotherAlbum != 'a')
    					isTrue = 0;*/
    		
    	}
    scanf("%c", &inputTest);
    	
    
    	return 0;
    
    }
    Last edited by thescratchy; 02-17-2010 at 12:28 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Question about scanf and spaces or whitespace
    By jensbodal in forum C Programming
    Replies: 4
    Last Post: 11-26-2009, 04:12 PM
  2. scanf return values
    By pirog in forum C Programming
    Replies: 15
    Last Post: 09-13-2009, 03:58 AM
  3. Can not get this program to work?
    By BLG in forum C Programming
    Replies: 9
    Last Post: 09-09-2009, 09:28 AM
  4. If you are employed as a programmer, please look
    By Flood Fighter in forum A Brief History of Cprogramming.com
    Replies: 10
    Last Post: 09-28-2004, 02:35 AM
  5. scanf - strtok and space as delimiter?
    By Bill Cosby in forum C Programming
    Replies: 6
    Last Post: 09-20-2004, 06:45 PM