In a string, how can i separe important values in char or in different string values? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

In a string, how can i separe important values in char or in different string values?

For an exemple, i have (lettre 1, lettre 2) "(T, G)". I want to output them as 2 different string values. How can i separe T and G? Thx for your help

13th Aug 2022, 4:39 PM
eloufou
eloufou - avatar
13 Answers
+ 2
So the idea was to get letters only from this string "{T, G}" and make a string array from the letters found? is that it?
13th Aug 2022, 4:49 PM
Ipang
+ 2
eloufou do you mean something like this just for clarification https://code.sololearn.com/cJM48U35WsOR/?ref=app
13th Aug 2022, 5:28 PM
BroFar
BroFar - avatar
+ 2
eloufou scanf is c lang whereas cin >> is cpp and is for input
13th Aug 2022, 5:41 PM
BroFar
BroFar - avatar
+ 2
Alright, you gave me a pretty good path to go on! Thx to BroFar and Ipang. It's very appreciated
13th Aug 2022, 5:59 PM
eloufou
eloufou - avatar
+ 1
Ipang Yes
13th Aug 2022, 4:53 PM
eloufou
eloufou - avatar
+ 1
eloufou Have you tried? I'd like to see your tryout code so I can check what's wrong. Please save the code as code bit, and attach its link in post Description https://www.sololearn.com/post/75089/?ref=app
13th Aug 2022, 5:06 PM
Ipang
+ 1
Yes eloufou and I gave you a hint on finding vowels and need to add a counter int
13th Aug 2022, 5:57 PM
BroFar
BroFar - avatar
+ 1
Sorry Eloufou Fell asleep it was late when I wrote my last response. Use a for...loop to iterate the string. You can follow BroFar's path as in the example given Use conditionals `if` or `switch` to verify whether the character was a vowel If it was, add the character to the result string. Otherwise, ignore the character. You can then get the result string length as vowel counter. You can evade the need of additional string and simply use a counter variable also, it's all your choice. Happy trying, and don't hesitate to ask along the way ...
13th Aug 2022, 10:26 PM
Ipang
0
Ipang, i havent tried because i have no idea... like really, no idea
13th Aug 2022, 5:13 PM
eloufou
eloufou - avatar
0
Yea but is there something simpler
13th Aug 2022, 5:35 PM
eloufou
eloufou - avatar
0
BroFar Ipang, something like the function scanF
13th Aug 2022, 5:37 PM
eloufou
eloufou - avatar
0
Go see the challenge called vowel counter in the app... im just tryna do this one Ipang BroFar
13th Aug 2022, 5:41 PM
eloufou
eloufou - avatar
0
Ok so if I understand, getLine(cin, var) is the function to read in a string? BroFar Ipang
13th Aug 2022, 5:50 PM
eloufou
eloufou - avatar