2
#include<stdio.h>
 
int main(){
    
    int score[1001], j, n = 3;
    char name[4][11];
    
    for(j = 0; j < n; j++){
            
            scanf("%[^#]#%d", name[j], &score[j]);
    
        }
    
    for(j = 0; j < n; j++){
            
            printf("%s %d", name[j], score[j]);
            
        }
}

I dont know why it automatically adds a \n when I print it. I expected it to just take the string that I inputted and nothing more. An example of an input is "Jojo#40" where Jojo would be taken as string and 40 as int. Is there a way to fix this or a better way to take those inputs?

Zac Anger
  • 6,983
  • 2
  • 15
  • 42
lazerbs
  • 21
  • 2

0 Answers0