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

Frequently Asked Questions

How do I read a String/int/boolean/etc from the keyboard?

Java Programmer's FAQ
The easiest way is to pick up the source for the 100% pure Java class EasyIn from http://www.afu.com/ (same place as this FAQ) Compile it with your code and use it like this: EasyIn easy = new EasyIn(); int i = easy.readInt(); // gets an int from System.in boolean b = easy.readBoolean(); // gets a boolean from System.in double d = easy.readDouble(); // gets a double from System.in ... etc.

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. See similar questions...

How can I read a single character from the keyboard without waiting for a newline?

Infrequently Asked Questions in comp.lang.c
The buffer is normally at ''&main - 0100''. Lower if you have more than 256 characters of typeahead. See similar questions...

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. See similar questions...

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" . See similar questions...

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. See similar questions...

How can I show an int as a binary number - a string of 1s and 0s?

FAQ for the microsoft.public.languages.csharp newsgroup
The Convert class has an overload of the static ToString() method that takes two ints and returns a string populated with the number in the specified base. For instance, calling Convert.ToString(128, 2) will return "10000000". See similar questions...

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++ // .. See similar 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. See similar questions...

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. See similar questions...

Why does (read-from-string "foobar" :start 3) return FOOBAR instead of BAR?

Frequently Asked Questions for comp.lang.lisp
READ-FROM-STRING string &OPTIONAL eof-error-p eof-value &KEY :start :end :preserve-whitespace When a function takes both types of arguments, all the optional arguments must be specified explicitly before any of the keyword arguments may be specified. In the example above, :START becomes the value of the optional EOF-ERROR-P parameter and 3 is the value of the optional EOF-VALUE parameter. To get the desired result, you should use (read-from-string "foobar" t nil :start 3). See similar questions...

What clefs must a string player be able to read?

CMNC FAQs.
That depends on what instrument you play. Violins only have to deal with treble. An intermediate cello player should be able to read and play both bass and tenor clef, and being able to read treble cleff is highly desirable. An advanced cello player should be able to read and play from the bass, tenor, treble, and transposed treble clef (reading the treble clef and playing an octave down). A viola player should be able to read and play from both the alto and treble clefs. See similar questions...

What is a Boolean Network or NK model ?

Self-Organizing Systems FAQ for Usenet newsgroup comp.theory...
Taking a collection (N) of logic gates (AND, OR, NOT etc.) each with K inputs and interconnecting them gives us a Boolean Network. Depending upon the number of inputs (K) to each gate we can generate a collection of possible logic functions that could be used. By allocating these to the nodes (N) at random we have a Random Boolean Network (RBN - also called a Kauffman Net or the Kauffman Model) and this can be used to investigate whether organization appears for different sets of parameters. See similar questions...

How do I split a string?

Frequently Asked Questions for comp.lang.lisp
There is no 'right' answer to this question; many lisp programmers have rolled their own solution in the past, and others are of the view that it should never be necessary, as long as all sequence functions are used with consistent :start and :end arguments. However, a community-based 'standard' was developed in June/July 2001 on comp.lang.lisp; known as SPLIT-SEQUENCE (formerly PARTITION), it works as follows in its simplest form: split-sequence #\Space "A stitch in time saves nine. See similar questions...

How do I find/configure the SNMP read-only community string for my devices?

Klir - Frequently Asked Questions
An SNMP read-only community string/name acts as a password to access device or application data. Refer to your device, operating system or application documentation for instructions on how to configure SNMP. The SNMP read-only community string(s) set on your devices (e.g. public) must be entered in the Find/Add Devices screen in order for them to be added to the system for monitoring. See similar questions...

How can I read a single character from the keyboard under UNIX and DOS?

Perl FAQ
A closely related question to the no-echo question below is how to input a single character from the keyboard. Again, this is a system dependent operation. As with the previous question, you probably want to get the ReadKey extension. The following code may or may not help you. See similar questions...

How can I read the keyboard faster than ngetchx, but easier than _rowread?

Frequently Asked Questions
Yes, there is a LEGAL method to pick keystrokes directly from the keyboard queue. See kbd_queue and other queuing functions from system.h header file. See similar questions...

What is a Boolean search?

Thinkfinty Frequently Asked Questions
A Boolean search uses selected words and symbols (e.g., AND, OR, and NOT) to specify exactly what should and should not be included in a search query. It was developed and named after George Boole (1815-1864), a British mathematician and logician. Thinkfinity's Advanced Search permits the use of Boolean search terms. Go to Thinkfinity Boolean Phrase Help for information on how you can use it to refine your searches. See similar questions...

Explore Other Topics

What is a Detached Retina?
Why should I have Financial Statements prepared and how often is it necessary?
How do I calculate my LDL?
What are the educational requirements to becoming a chief judge?
What eye shadow colors go well with hazel (brown/green) eyes?
What colors look best on a red headed person with dark brown eyes?
What are the effects of Microbial Contamination?
Do I have to go to court to obtain a divorce?
MY dentist says I have gum recession that requires gum grafts. Can the BOST technique avoid this?
Parabens are in almost all cosmetics. What are they, and why do you not use them?
How do I pass parameters to a popup window?
What causes anemia during pregnancy?
How do I obtain/file my military discharge?
I get the error message Can't open file: 'yourPrefix_tableName.MYI' or similar. What's wrong?
More Questions >>

© Copyright 2007-2012 QueryCAT
About • Webmasters • Contact