is there an easy command to read from a file all the numbers which are stored in the file.
lets say we have the file arraydata.dat:
3 929 942.3 -2 0 28 92
//and so on.......
Type: Posts; User: derek tims
is there an easy command to read from a file all the numbers which are stored in the file.
lets say we have the file arraydata.dat:
3 929 942.3 -2 0 28 92
//and so on.......
daved: basically, the code i was given did work ok. but i sometimes needed to press ENTER more than once to go to the next step. so fiddling around with it i tried a few combinations, and what i have...
it works.........
no matter what i do, it seems to work fine.
type 0 in starihgt away, works fine.
type in any garbage in, press enter, get the please re-enter, enter 0, and it works.
thanks for the help!!
here's what i've come up with, and it seems to work.
cin >> a;
z = a; // setting z = a, and so can later allow an input of zero.
// without this, it would...
!(a) means not equal to a.
do u mean that for boolean, if false it is always 0, and if true always 1?
so from what i gather, by setting a = 0, it will appear to be false.
basically, in my program, i want to enter ANY number, including 0. if i enter anything other than a number, it will ask to re-enter.
BUT, when i enter 0, it asks me to re-enter, yet 0 should be...
thank you VERY much!!
have (i think sorted it. so much easier than what i was trying to do!! :) )
its when i input q that i want to check.
ie.
cin >> q;
check q for any chars, if so, then fail.
i have never used cin.getline before........ how would i go about using it?
basically, i'm asking for a number of strips, and so this has to be an integer.
now what i have done is made it so that when u enter the number of strips, it saves it as a string in a file.
...
i have figured it. i've been editing in a dos window previously, and the || won't work.
opening it up in notepad, and trying that works just fine.
glad that's sussed!! thanks for the advice. :)
i think it may be my version i'm running. just downloaded a piece of source code that had the || in it, and it failed to compile.
i'm running the free borland 5.5 version.
oops...... how silly. of course it is enclosed within an if statement. i will edit the post for more accuracy.
if i really need to post my code then of course, i will.............
but, i'm not sure if it'll make the slightest difference a its fairly long. i would just like to be able to use the or...
i using borland c++ version 5.5, and when trying to do the or operator, which is denoted by ||, it says the symbol | is an illegal character.
I'm presuming this to mean i don not have the correct...
ok, well what i have done is when i enter n, i store that value as a string.
now then, i read from that file, an integer q, and read the same value, a float p.
then i set up a while loop saying...
ok, this is what i have. apologies for incorect formatting, i'm new to this. i'm having to go out in a few minutes so i won't reply for a while either.
#include <iostream.h>
#include...
slymaelstrom: yes, but for some reason it wouldn't work when i entered a float.
no idea why. prob me!!
but it worked for when i entered a character, just not a float, and it needs to be a float.
sorry, n is an integer.
I'm working on an integration program, that works out the integation by approximating with the rectangle rule.
I am trying to ask how many strips do you want? This MUST be an integer, yet if i...
awesome..... thanks. :)
What i am trying to do is to set a value for a. the value should be a number (float).
but i need to make it so that if a char is entered, then the program will end, or say something like "this is...
ok, thanks for the advice. i think i will give the parser a miss!!
it wasn't asked of me, i just thought it would be good to have it though, but its probably not worth it.
i will have a quick...
Basically, what i am trying to do, is write a program that will integrate a function using the rectangle method.
I'm fine with the maths part.
And i can declare a function within the actual...