Hello
I wrote a code which is suppose to read a file which contains lines of
double and prints it out.
thanks for helping
double.txt***** *************** *************** ****
1.01
2.0301
3.0604
4.10101
5.15202
in a stack.h I have
//stack.h******** *************** *************** **
#ifndef STACK_H
#define STACK_H
struct Stack
{
struct Link
{
void* data;
Link* next;
void initialize (void* dat, Link* nxt);
}
* head;
void initialize ();
void push (void* dat);
void* peek ();
void* pop ();
void cleanup ();
};
#endif
in my main.cpp
string line;
while(getline(i n, line)){
textlines.push( reinterpret_cas t<void*>(&line) );
}
works ok but the following is not printing out the lines
double* s;
while(( s = static_cast<dou ble*>(textlines .pop() )) != 0) {
cout << *s << endl;
delete s;
}
[color=blue]
> LocalWords: txt ifndef struct endif cpp ok[/color]
I wrote a code which is suppose to read a file which contains lines of
double and prints it out.
thanks for helping
double.txt***** *************** *************** ****
1.01
2.0301
3.0604
4.10101
5.15202
in a stack.h I have
//stack.h******** *************** *************** **
#ifndef STACK_H
#define STACK_H
struct Stack
{
struct Link
{
void* data;
Link* next;
void initialize (void* dat, Link* nxt);
}
* head;
void initialize ();
void push (void* dat);
void* peek ();
void* pop ();
void cleanup ();
};
#endif
in my main.cpp
string line;
while(getline(i n, line)){
textlines.push( reinterpret_cas t<void*>(&line) );
}
works ok but the following is not printing out the lines
double* s;
while(( s = static_cast<dou ble*>(textlines .pop() )) != 0) {
cout << *s << endl;
delete s;
}
[color=blue]
> LocalWords: txt ifndef struct endif cpp ok[/color]
Comment