I'm trying to solve a basic problem where I have to print a string a output I complete my code and submitted it for test case it prints the correct output but it includes a newline character at the beginning of the output string, due to this the test case fails.
the Input is in the form of:
Arun:40:51:60
roger:49:51:62
steve:80:71:60
The output should be the name of the student with the highest score: steve
but my program outputs: " steve"
this is my program:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
    int val=0,topMark=0;
    char topStudent[101];
    scanf("%d",&val);
    for(int i=0;i<val;i++)
    {
        char arr[101]; 
        int m1,m2,m3;
        scanf("%[^:]:%d:%d:%d",arr,&m1,&m2,&m3);
        if(topMark<(m1+m2+m3))
        {
            topMark=m1+m2+m3;
            strcpy(topStudent,arr);
        }
    }
    puts(topStudent[i]);   
}
I tried using both printf and puts functions, but it still prints a new line.
I'm expecting a way to get the input without the newline character at the beginning of the string or printing the string without the newline character at the beginning.
 
    