All Questions

155
votes
14answers
400361 views

How can I read inputs as integers?

Why does this code not input integers? Everything on the web says to use raw_input(), but I read on Stack Overflow (on a thread that did not deal with integer input) that raw_input() was renamed to i...
340
votes
10answers
43151 views

"is" operator behaves unexpectedly with integers

Why does the following behave unexpectedly in Python? >>> a = 256 >>> b = 256 >>> a is b True # This is an expected result >>> a = 257 >>> b = 2...
2291
votes
31answers
4818046 views

How do I convert a String to an int in Java?

How can I convert a String to an int in Java? My String contains only numbers, and I want to return the number it represents. For example, given the string "1234" the result should be the number 123...
891
votes
12answers
318262 views

What is the difference between const int*, const int * const, and int const *?

I always mess up how to use const int*, const int * const, and int const * correctly. Is there a set of rules defining what you can and cannot do? I want to know all the do's and all don'ts in terms ...
1077
votes
20answers
1901760 views

Easiest way to convert int to string in C++

What is the easiest way to convert from int to equivalent string in C++. I am aware of two methods. Is there any easier way? 1. int a = 10; char *intStr = itoa(a); string str = string(intStr); 2....
334
votes
25answers
759545 views

How can I convert String to Int?

I have TextBoxD1.Text and I want to convert it to 'int' to store it in a database. How can I do this?
78
votes
10answers
90272 views

Quickest way to convert a base 10 number to any base in .NET?

I have and old(ish) C# method I wrote that takes a number and converts it to any base: string ConvertToBase(int number, char[] baseChars); It's not all that super speedy and neat. Is there a good, ...
520
votes
26answers
475768 views

How to concatenate a std::string and an int?

I thought this would be really simple but it's presenting some difficulties. If I have std::string name = "John"; int age = 21; How do I combine them to get a single string "John21"?
273
votes
11answers
852371 views

Convert string to int C++

Just have a quick question. I've looked around the internet quite a bit and I've found a few solutions but none of them have worked yet. Looking at converting a string to an int and I don't mean ASCI...
1246
votes
24answers
987032 views

Get int value from enum in C#

I have a class called Questions (plural). In this class there is an enum called Question (singular) which looks like this. public enum Question { Role = 2, ProjectFunding = 3, TotalEmploy...

Previous Next