Is it possible to point to a certain index of a value? For example, int x = 2576, is it possible to do something like x[2]? I know you can do it with strings, but can you do it with numbers?
NoUserNameHere
0
Newbie Poster
Recommended Answers
Jump to PostPossible, but not directly. The two options are basically to convert the number to a string and index that, or write a function that separates the number arithmetically and returns the digit at the selected index.
Edit:
Just for giggles, here's a fun example. :)
#include <algorithm> …
All 2 Replies
Reply to this topic
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.