Re: A question for C programmers about getgrnam

2001-01-30 Thread Thomas Dodd
John Summerfield wrote: > > > John Summerfield wrote: > > > > > > I have a code fragment: > > > struct group *grp = getgrnam(group.data()); > > > > you have to use group.c_str() since .data() doesn't have a \0 terminator. > > Filled with disbelief ( the C++ primer DOES use the wo

Re: A question for C programmers about getgrnam

2001-01-30 Thread John Summerfield
> John Summerfield wrote: > > > > I have a code fragment: > > struct group *grp = getgrnam(group.data()); > > you have to use group.c_str() since .data() doesn't have a \0 terminator. Filled with disbelief ( the C++ primer DOES use the word "string"), I tried it. It works. W

Re: A question for C programmers about getgrnam

2001-01-30 Thread Thomas Dodd
John Summerfield wrote: > > According to the C++ primer which I have before me, > The data() method returns a pointer to the first element of a string formed > by copying elements from the range [begin,end). > > (the broken bracket/parentheses pairing belongs to the book too). It deals with no

Re: A question for C programmers about getgrnam

2001-01-30 Thread Levente Farkas
John Summerfield wrote: > > I have a code fragment: > struct group *grp = getgrnam(group.data()); you have to use group.c_str() since .data() doesn't have a \0 terminator. -- Leventehttp://petition.eurolinux.org/index_html "The only thing worse than not

Re: A question for C programmers about getgrnam

2001-01-30 Thread John Summerfield
I'm leaving the other bits in for those who like the whole story. This works: { // validate program name struct stat statbuf; int statret=stat(program.data(),&statbuf); if (statret == -1) { cer

Re: A question for C programmers about getgrnam

2001-01-30 Thread Thomas Dodd
John Summerfield wrote: > > I have a code fragment: > struct group *grp = getgrnam(group.data()); > if (grp == NULL) > { > int E=errno; > cerr << "error=" << E << ": " << strerror(E) << " " << >ENOM

A question for C programmers about getgrnam

2001-01-30 Thread John Summerfield
I have a code fragment: struct group *grp = getgrnam(group.data()); if (grp == NULL) { int E=errno; cerr << "error=" << E << ": " << strerror(E) << " " << ENOMEM<< endl;; cer