How can i store in an integer array a negative number of type string?i mean i want it to be recognized that it is a negative nr.

Recommended Answers

All 2 Replies

What is a "negative number of type string?"

Just a wild guess at what you want but a negative number can be represented in a string simply by the negation operator like so : string negativeFive = "-5" .
Then if you want to convert it back, then you can check if negativeFive[0] == '-' and if it is then start from position 1 and use the usual conversion from a positive string number to a integer. And then depending on whether we started at position 1 or not, you can negate the result.

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.