In a string, how can i separe important values in char or in different string values? | Sololearn: Learn to code for FREE!

-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

8/13/2022 4:39:16 PM

eloufou

13 Answers

New Answer

+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?

+2

eloufou do you mean something like this just for clarification https://code.sololearn.com/cJM48U35WsOR/?ref=app

+2

eloufou scanf is c lang whereas cin >> is cpp and is for input

+2

Alright, you gave me a pretty good path to go on! Thx to BroFar and Ipang. It's very appreciated

+1

Ipang Yes

+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

+1

Yes eloufou and I gave you a hint on finding vowels and need to add a counter int

+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 ...

0

Ipang, i havent tried because i have no idea... like really, no idea

0

Yea but is there something simpler

0

BroFar Ipang, something like the function scanF

0

Go see the challenge called vowel counter in the app... im just tryna do this one Ipang BroFar

0

Ok so if I understand, getLine(cin, var) is the function to read in a string? BroFar Ipang