Hey, I am trying to find a way to compare a string with a long long int. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Hey, I am trying to find a way to compare a string with a long long int.

I tried the stoll method of std lib and also tried converting the long long int into string, but nothing is giving me an equality even though the contents there are the same. Can someone please tell me how to compare these two and check for their equality? Thanks

21st Aug 2022, 11:25 AM
Ruchika Sehgal
Ruchika Sehgal - avatar
2 Answers
+ 2
You can use stoll() function which converts string to long long int value.. Ex: cout << (12445578999999999== stoll("12445578999999999")); edit: hope this helps.. https://www.google.com/amp/s/www.geeksforgeeks.org/stdstol-and-stdstoll-functions-in-c/amp/ edit: oh.. am not read question fully but i think answer is suitable...!!
21st Aug 2022, 12:11 PM
Jayakrishna 🇮🇳
+ 2
Hello Ruchika, Can you add a link to the code bit you're working on. Idk if I understood your intention well, but to my understanding, the two types are of a different kind, so I need to know what exactly did you mean by "compare a string with a long long int".
21st Aug 2022, 2:42 PM
Ipang