• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Simple class, datatype question

Krakerjak

Senior member
I have this code, which will accept a value and print it out.
This is a simple beginners class, yes....im a noob.

My problem isnt with the class, in fact the code works fine *** (with cin/cout).
I initially had made it without using cin, cout statements but i just couldn't find a way
to accept user input (character string - resistance value from 1 - 10 meg) ......to be stored as a long int.
From what i found in the library functions i got atoul(), and atol(). But these functions are hairy, and dont seem
to coonvert correctly for numbers larger than 32000 ish.

After much thinking, i gave in and used cin to a long variable...piece of cake

What i'm really wondering is, is there not an easy way to do this without using cin cout???
I dont have anything against their use, i just believe that there must be a way to do this, i'm obvoiusly
missing something important that stops me from doing this the first way i had planned.

***Technically it doesn't

(also, does anybody know why the program gets stuck in a loop with iostream.h at "return *this" line, and will constantly
print " ____is not a valid resistance please enter a value form 1 - 10 mag ohms :" over and over again)??
 
for a console app you must read from one of these:
* cin (or stdin using C-style functions)
* a file
* command-line parameter using argv (just like you pass a filename to a compiler. so "myapp.exe 10" passes 10 as character string)

If you're writing a windowed / graphical app then you can have a text-input box.
 
Back
Top