QueryCAT Logo
Search 5,000,000+ questions and answers.

Frequently Asked Questions

How do I convert a string to a double or int? What plays the role of atof and atoi in C#?

Windows Forms FAQ - Windows Forms from MFC
You use static members of the Convert class found in the System namespace to handle conversions in the .NET framework.

How to convert an int to a char array or C++ string?

Tech Talk about C++ and C Issues / Comeau C++ and C FAQ
How to add a float (or "any" type really) to the end of a C++ string? Unlike routines like atoi mentioned in the previous question, there is no direct routine such as itoa available. However, similar to the string I/O routines in the previous question, one can do this: #include <stdio.h> // cstdio in C++ // ..

How can I convert from string to int ?

C++ corner
You want to make a function that converts from a type to another. Like from std::string to int, or the other way around. This can be done using std::stringstream and insertion / extraction operators. Just as above, templates will prove of great help: Its usage is not as straightforward as the above explained max template. Normally, you would want to call it like "int value = lexical_cast( myStdString );". There is, however, a problem.

How do I convert a string to an int etc?

FAQ for the microsoft.public.languages.csharp newsgroup
In general, when you want to convert from one type to another, the first class to look at is System.Convert. It has a load of static methods which are likely to help you. If you're converting from a String, you could also check whether the type that you want to convert to has a Parse method or something similar - for instance, I usually use DateTime.ParseExact to convert from a String to a DateTime.

Sect. 18) How do I convert a String to an int?

Java Programmer's FAQ - Part D
There are several ways. The most straightforward is: String myString = numString.trim(); int i = Integer.parseInt(myString); long l = Long.parseLong(myString) or String myString = numString.trim(); i = Integer.parseInt(myString,myIntRadix); Note 1: There is a gotcha with parseInt - it will throw a NumberFormatException for String values in the range "80000000" to "ffffffff". You might expect it to interpret them as negative, but it does not. The values have to be "-80000000" .

Sect. 18) How do I convert an int to a string?

Java Programmer's FAQ - Part D
Try any of these: String s = String.valueOf(i); or String s = Integer.toString(i); or String s = Integer.toString(i, radix); or // briefer but may result in extra object allocation. String s = "" + i; Note: There are similar classes for Double, Float, Long, etc.

How can I convert numbers to strings (the opposite of atoi)? Is there an itoa function?

Infrequently Asked Questions in comp.lang.c
There's frequently an itoa function. Better yet, write your own; it'll be good practice. On some implementations, (char *) x; will convert x to a string.

How can I convert an INT into CHAR*/STRING or vice versa?

Beginner FAQ - GPWiki
This is something you do a lot in programming and pretty much every language makes it easy to convert between types. You may have already printed integers to the console with COUT or PRINTF, which of course needs to be converted to a string first. Converting numbers to strings is done in a similar way. Boost is a C++ library that can help you with problems like these and many others.

How should I round a double up to an int? Q: How do I get the name of the operating system?

Code Style: Java programming frequently asked questions (FAQ...
To get the operating system name in Java use the static System.getProperty("os.name") method, which returns a string. Other operating system property keys are "os.arch" for the hardware architecture and "os.version" for the version number. A recursive method is one whose method body includes a call to itself, so that it is called repeatedly until an expected condition is met or it cannot continue the recursion any longer.

c In a call to malloc, what does an error like ''Cannot convert 'void *' to 'int *''' mean?

All Questions
I wrote a little wrapper around malloc, but it doesn't work: #include <stdio.h> #include <stdlib.h> mymalloc(void *retp, size_t size) { retp = malloc(size); if(retp == NULL) { fprintf(stderr, "out of memory\n"); exit(EXIT_FAILURE); } } I'm trying to declare a pointer and allocate some space for it, but it's not working.

How do I convert a string to a number?

Updating the For Beginners forum FAQ - GameDev.Net Discussio...
I am including the header file <string>, and I am using the string class, but the code doesn't compile? (namespace resolution, having the std:: topics) How do I use unique() with vectors? (answered only once, but still a good question to have due to people not knowing that it's possible to do)

What kind of manual work will I have to do after I convert from VB to C#?

Frequently Asked Questions (FAQ) about C-Sharpener For VB
Please see Limitations and Workarounds (PDF file) for more details. You may also want to look at some sample converted projects.

Q Can we have more hands on with role-plays?

Customer Service Training FAQ Jeff Gee McNeil and Johnson Le...
A Yes. We customize our programs to meet your needs. If you want more role- playing, we work that into the program. A Yes. All our programs are stand-alone pieces that can be used together or alone. You tell us what you need and we will provide it. We’re not the most expensive and we’re not the least expensive. Like all excellent training programs, you are paying for the knowledge, skill and instructional design elements that go into producing practical, performance based training.

How to convert the datetime into a string for use in the SQL ' statement?

Megasolutions.net :: Asp.Net Frequently Asked Questions - FA...
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Private Sub ddlCulture_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ddlCulture.SelectedIndexChanged

How do I convert an integer to a string representation?

CSC 209 Summer 2006
Well, printf does it for output, so look at its related function named sprintf that "prints formated output to a string."

How can I convert an integer or a float to a string?

Frequently Asked Questions
It's easy. Use sprintf. For example: char string1[50]; char string2[50]; short int var1; float var2; ... sprintf (string1, "%d", var1); sprintf (string2, "%f", var2);

Explore Other Topics

Can I have the colonoscopy if I am on my menstrual period?
Can I paint over existing aluminum or vinyl siding?
What ingredients are used to make meth?
How do I obtain a voter registration card?
What are the health benefits of eating Feta Cheese?
What is maltitol syrup?
What color grout should I use?
raquo; What is a lethal dose of cocaine?
Can I bake biscuits in a toaster oven?
How do I to test a rectifier?
What language is spoken in Madrid?
What is the meaning of turnover? Is it the same as "sales"?
Can you mix Engine Ice with other products or types of coolant and antifreeze?
Can the spleen ever grow back?
Can I change a partition's cluster size with Partition Resizer, and keep my data?
More Questions >>

© Copyright 2007-2009 QueryCAT
About • Webmasters • Contact