[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cobalt-developers] Help: error when reading a file with C++



Hello Pascal,

dont know why, but if you move char * buf; before calling open, it wont dump core:

#include <iostream>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
void main ()
{
    char * buf;
    int fd = open("essai.txt", O_RDWR);
    for (;read(fd, buf, 1);)
        cout << *buf;
}

Cheers,
Paulo

Pascal Genest wrote:
Hello !
I use this code : #include <iostream>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
void main ()
{
    int fd = open("essai.txt", O_RDWR);
    char * buf;
    for (;read(fd, buf, 1);)
        cout << *buf;
}
The program return a lot of « Z » and read not the file only on a
cobalt.
Thanks for your response Pascal.



_______________________________________________
cobalt-developers mailing list
cobalt-developers@xxxxxxxxxxxxxxx
http://list.cobalt.com/mailman/listinfo/cobalt-developers

.



--
Paulo Rodrigues
Professional Services / MIS
prodrigues@xxxxxxxxxxxxxx