In strtok() function can we pass first argument as a string.
like:
string s
strtok(s," ")
Strtok() inbuilt function
No…it will work only for array of characters( C- style string).
PROBLEM: In Little Flowers Public School, there are many students with same first names. You are given a task to find the students with same names. You will be given a string comprising of all the names of students and you have to tell the name and count of those students having same. If all the names are unique, print -1 instead. Note: We don’t have to mention names whose frequency is 1. INPUT: The only line of input will have a string ‘str’ with space separated first names of students. TEST CASES: Input 1: Abhishek harshit Ayush harshit Ayush Iti Deepak Ayush Iti Output 1: harshit 2 Ayush 3 Iti 2 Input 2: Abhishek Harshit Ayush Iti Output 2: -1
i have commented the problem inside ide https://ide.codingblocks.com/s/223953 and also attempted to solve using strtok() function but it is not showing any output why?
In while loop temp is of type char* and r is of type string and u are not using c_str
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.