+ 6
How can I take input from user like this
Sample Input: 3 Nick Dunburry Tommy Newborne David James
9 Antworten
+ 7
char str[100];
int i;
for(i=0;i<3;i++)
scanf("%[^\n]",str);
Like this
+ 7
char str[100];
int i;
for(i=0;i<3;i++)
scanf("%[^\n]",str);
If I go like this and when i=1 in str Tommy Newborne will be stored replacing Nick Dunburry
Am I wrong?
+ 6
Initials +50 XP
You are given a list of names for a fundraiser, but you need to keep the names relatively anonymous. You are tasked with getting the initials for each name provided.
Task:
Given a list of first and last names, take the first letter from each name to create initials and output them as a space-separated string.
Input Format:
The first input denotes the number of names in the list (N). The next N lines contain the list elements as strings.
Output Format:
A string containing the initials of each name in the original list, separated by spaces.
Sample Input:
3
Nick Dunburry
Tommy Newborne
David James
Sample Output:
ND TN DJ
This is the question
+ 5
No it's 3 name another being sir name
+ 3
How you tried till now about that..?
+ 2
Use a 2dimentional charecter array. And read names by scanf("%s", arr[i]) ; where arr is 2d array..
char str[7][100];
int i;
for(i=0;i<7;i++)
scanf("%s",str[i]);
Like this you can have 7 strings..
Edit: Welcome To Hell
Is that 3 names or 6? I assumed 6..
So to read entire line:
char str[3][100];
int i;
for(i=0;i<3;i++)
scanf("%[^\n]",str);
+ 2
Yes. By that way you specified, it replaces with next input..
You need to Use a 2dimentional charecter array, as I specified..
First read N.
You can go with reading single word by %s, then read N*2 words and just print first letters...
Or
Read entire name, by looping N times only.. Then you need print 1st letter + letter after a space.. This can done by loop or by strtok..