f



getting a warning about gets

I'm getting a warning on my linux gcc compiler:

/tmp/ccXgHa9s.o(.text+0x48): In function `main':
: warning: the `gets' function is dangerous and should not be used.

And here's where I used gets:

#include "common.h"  //common.h includes string.h
....
....

int main(void)
{
   char zf_name[50];

   ....
   printf("Enter the name of the file\n");
   gets(zf_name);
   ...
   return 0;
}


0
Broli00 (429)
5/19/2008 10:38:59 AM
comp.lang.c 30657 articles. 5 followers. spinoza1111 (3246) is leader. Post Follow

16 Replies
1108 Views

Similar Articles

[PageSpeed] 1

On May 19, 10:38=A0am, pereges <Brol...@gmail.com> wrote:
> I'm getting a warning on my linux gcc compiler:
>
> /tmp/ccXgHa9s.o(.text+0x48): In function `main':
> : warning: the `gets' function is dangerous and should not be used.
>
> And here's where I used gets:
>
> #include "common.h" =A0//common.h includes string.h
> ...
> ...
>
> int main(void)
> {
> =A0 =A0char zf_name[50];
>
> =A0 =A0....
> =A0 =A0printf("Enter the name of the file\n");
> =A0 =A0gets(zf_name);
> =A0 =A0...
> =A0 =A0return 0;
>
>
>
> }- Hide quoted text -
>
> - Show quoted text -

I think the message is rather explicit; gets() is dangerous, and
shouldn't be used.

Alternatively, use fgets() or perhaps, scanf() to get input

--
include
0
inclood (1)
5/19/2008 10:47:02 AM
Hi

On May 19, 11:38 am, pereges <Brol...@gmail.com> wrote:

> : warning: the `gets' function is dangerous and should not be used.
>    char zf_name[50];
>    gets(zf_name);


How do you know the file name is less than 50 characters?

Use:
    char zf_name[ SOME_CONSTANT ];
    fgets( zf_name, SOME_CONSTANT, stdin );

This will at least not overflow your buffer.

You should also do:

if( ferror( stdin )) /* there was a read error */

if( zf_name[ strlen(zf_name) - 1 ] == '\n' )
  zf_name[ strlen(zf_name) - 1 ] = 0;  /* take the newline character
off the filename */

else
  /* line was longer than SOME_CONSTANT, and part of it is missing */


and maybe also:

if( feof( stdin )) /* end of file was reached */


HTH
viza
0
tom.viza (34)
5/19/2008 10:54:31 AM
On May 19, 1:54 pm, viza <tom.v...@gmail.com> wrote:
> Hi
>
> On May 19, 11:38 am, pereges <Brol...@gmail.com> wrote:
>
> > : warning: the `gets' function is dangerous and should not be used.
> >    char zf_name[50];
> >    gets(zf_name);
>
> How do you know the file name is less than 50 characters?
>
> Use:
>     char zf_name[ SOME_CONSTANT ];
>     fgets( zf_name, SOME_CONSTANT, stdin );
>
> This will at least not overflow your buffer.
>
> You should also do:
>
> if( ferror( stdin )) /* there was a read error */
Does not necessarily mean there was a read error. It could have been
that EOF was reached.
if(!feof(stdin) && ferror(stdin)) means an error happened.
> if( zf_name[ strlen(zf_name) - 1 ] == '\n' )
First check that strlen(zf_name) > 0
>   zf_name[ strlen(zf_name) - 1 ] = 0;  /* take the newline character
> off the filename */
>
> else
>   /* line was longer than SOME_CONSTANT, and part of it is missing */
Not necessarily again. Most of the times that's what it means. If EOF
wasn't reached, you can try to read a byte from stdin with getc. If
getc returns EOF, check the stream if feof(). If feof() returns a
positive value, then the line wasn't longer than SOME_CONSTANT (unless
ferror() returns positive). If getc() does not return EOF, ungetc the
return value, and in that case yes; the line was longer than
SOME_CONSTANT.
0
vippstar (1211)
5/19/2008 11:13:19 AM
viza wrote:
> Hi
> 
> On May 19, 11:38 am, pereges <Brol...@gmail.com> wrote:
> 
>> : warning: the `gets' function is dangerous and should not be used.
>>    char zf_name[50];
>>    gets(zf_name);
> 
> 
> How do you know the file name is less than 50 characters?
> 
> Use:
>     char zf_name[ SOME_CONSTANT ];
>     fgets( zf_name, SOME_CONSTANT, stdin );
> 
> This will at least not overflow your buffer.
> 
> You should also do:
> 
> if( ferror( stdin )) /* there was a read error */

Why not check the value returned by fgets which will catch both an input 
error and an end-of-file? Then, if you need to distinguish between them 
can either ferror or feof.

If there was either an error or an end-of-file you want to avoid 
executing the code below.

> if( zf_name[ strlen(zf_name) - 1 ] == '\n' )
>   zf_name[ strlen(zf_name) - 1 ] = 0;  /* take the newline character
> off the filename */
> 
> else
>   /* line was longer than SOME_CONSTANT, and part of it is missing */
> 
> 
> and maybe also:
> 
> if( feof( stdin )) /* end of file was reached */

Well, that would need to be done up above when checking ferror rather 
than down here (which is probably what you intended but might not be 
obviouse to the OP).
-- 
Flash gordon
0
spam331 (4048)
5/19/2008 11:46:36 AM
Will this suffice:

if(scanf("%s", zf_name) != 1)
{
    perror("Erroneous file name!");
    exit(EXIT_FAILURE);
}


Or should I also check if the array limit is not exceeded ?
0
Broli00 (429)
5/19/2008 12:03:42 PM
On May 19, 5:03=A0am, pereges <Brol...@gmail.com> wrote:
> Will this suffice:
>
> if(scanf("%s", zf_name) !=3D 1)

As coded, this is no better than fgets. There are modifiers you can
place between the % and the s which will prevent buffer overflow but
it becomes even harder to determine if you received the entire file
name.  fgets is still the easiest to use.

> {
> =A0 =A0 perror("Erroneous file name!");
> =A0 =A0 exit(EXIT_FAILURE);
>
> }
>
> Or should I also check if the array limit is not exceeded ?

You cannot check this after the fact.  Once the limit is exceeded you
are in the realm of undefined behavior.

0
schwarz45 (78)
5/19/2008 12:23:34 PM
On May 19, 5:23 pm, Barry Schwarz <schwar...@yahoo.com> wrote:
> On May 19, 5:03 am, pereges <Brol...@gmail.com> wrote:
>
> > Will this suffice:
>
> > if(scanf("%s", zf_name) != 1)
>
> As coded, this is no better than fgets. There are modifiers you can
> place between the % and the s which will prevent buffer overflow but
> it becomes even harder to determine if you received the entire file
> name.  fgets is still the easiest to use.
>
> > {
> >     perror("Erroneous file name!");
> >     exit(EXIT_FAILURE);
>
> > }
>
> > Or should I also check if the array limit is not exceeded ?
>
> You cannot check this after the fact.  Once the limit is exceeded you
> are in the realm of undefined behavior.

I agree. What about the following code ?

if(fgets(zf_name, MAX_SIZE, stdin) == NULL)
{
  if(ferror(stdin))
  {
    perror("Error while reading file name!");
    exit(EXIT_FAILURE);
  }
  if(feof(stdin))
  {
    perror("End of file reached!");
    exit(EXIT_FAILURE);
  }
}

Also I'm wondering about the new line character which makes fgets
stops reading but is included in the string copied to zf_name.
Shouldn't we deal with it too ?
0
Broli00 (429)
5/19/2008 1:33:18 PM
On May 19, 4:33 pm, pereges <Brol...@gmail.com> wrote:
> On May 19, 5:23 pm, Barry Schwarz <schwar...@yahoo.com> wrote:
>
>
>
> > On May 19, 5:03 am, pereges <Brol...@gmail.com> wrote:
>
> > > Will this suffice:
>
> > > if(scanf("%s", zf_name) != 1)
>
> > As coded, this is no better than fgets. There are modifiers you can
> > place between the % and the s which will prevent buffer overflow but
> > it becomes even harder to determine if you received the entire file
> > name.  fgets is still the easiest to use.
>
> > > {
> > >     perror("Erroneous file name!");
> > >     exit(EXIT_FAILURE);
>
> > > }
>
> > > Or should I also check if the array limit is not exceeded ?
>
> > You cannot check this after the fact.  Once the limit is exceeded you
> > are in the realm of undefined behavior.
>
> I agree. What about the following code ?
>
> if(fgets(zf_name, MAX_SIZE, stdin) == NULL)
> {
>   if(ferror(stdin))
>   {
>     perror("Error while reading file name!");
>     exit(EXIT_FAILURE);
>   }
>   if(feof(stdin))
>   {
>     perror("End of file reached!");
>     exit(EXIT_FAILURE);
>   }
>
> }
>
> Also I'm wondering about the new line character which makes fgets
> stops reading but is included in the string copied to zf_name.
> Shouldn't we deal with it too ?
All your questions are answered in my previous post.
0
vippstar (1211)
5/19/2008 1:37:27 PM
vippstar@gmail.com writes:
> On May 19, 1:54 pm, viza <tom.v...@gmail.com> wrote:
[...]
>> if( ferror( stdin )) /* there was a read error */
> Does not necessarily mean there was a read error. It could have been
> that EOF was reached.

Um, yes, ferror(stdin) does mean that there was a read error.

> if(!feof(stdin) && ferror(stdin)) means an error happened.

That means that either an error or an end-of-file condition happened.

[snip]

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Nokia
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
0
kst-u (21963)
5/19/2008 3:27:46 PM
Keith Thompson said:

> vippstar@gmail.com writes:
>> On May 19, 1:54 pm, viza <tom.v...@gmail.com> wrote:
> [...]
>>> if( ferror( stdin )) /* there was a read error */
>> Does not necessarily mean there was a read error. It could have been
>> that EOF was reached.
> 
> Um, yes, ferror(stdin) does mean that there was a read error.
> 
>> if(!feof(stdin) && ferror(stdin)) means an error happened.
> 
> That means that either an error or an end-of-file condition happened.

It does? I'd have thought that it meant that both an error happened and an 
end-of-file condition /didn't/ happen. What am I missing?

-- 
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
0
rjh (10791)
5/19/2008 4:11:58 PM
vippstar@gmail.com wrote:
> On May 19, 1:54 pm, viza <tom.v...@gmail.com> wrote:
>> 

>> if( ferror( stdin )) /* there was a read error */
> Does not necessarily mean there was a read error.

That's wrong.

> It could have been that EOF was reached.
> if(!feof(stdin) && ferror(stdin)) means an error happened.

I'm guessing that you don't know
what the return value of feof means either.

N869
        7.19.10.2  The feof function
        Returns
        [#3]  The  feof  function returns nonzero if and only if the
        end-of-file indicator is set for stream.

        7.19.10.3  The ferror function
        Returns
        [#3]  The ferror function returns nonzero if and only if the
        error indicator is set for stream.

-- 
pete
0
pfiland (6613)
5/19/2008 4:20:23 PM
Richard Heathfield <rjh@see.sig.invalid> writes:
> Keith Thompson said:
>> vippstar@gmail.com writes:
>>> On May 19, 1:54 pm, viza <tom.v...@gmail.com> wrote:
>> [...]
>>>> if( ferror( stdin )) /* there was a read error */
>>> Does not necessarily mean there was a read error. It could have been
>>> that EOF was reached.
>> 
>> Um, yes, ferror(stdin) does mean that there was a read error.
>> 
>>> if(!feof(stdin) && ferror(stdin)) means an error happened.
>> 
>> That means that either an error or an end-of-file condition happened.
>
> It does? I'd have thought that it meant that both an error happened and an 
> end-of-file condition /didn't/ happen. What am I missing?

Nothing.  I just wasn't paying attention.  Whoops.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Nokia
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
0
kst-u (21963)
5/19/2008 4:39:50 PM
On May 19, 7:20 pm, pete <pfil...@mindspring.com> wrote:
> vipps...@gmail.com wrote:
> > On May 19, 1:54 pm, viza <tom.v...@gmail.com> wrote:
>
> >> if( ferror( stdin )) /* there was a read error */
> > Does not necessarily mean there was a read error.
>
> That's wrong.
>
> > It could have been that EOF was reached.
> > if(!feof(stdin) && ferror(stdin)) means an error happened.
>
> I'm guessing that you don't know
> what the return value of feof means either.
>
> N869
>         7.19.10.2  The feof function
>         Returns
>         [#3]  The  feof  function returns nonzero if and only if the
>         end-of-file indicator is set for stream.
>
>         7.19.10.3  The ferror function
>         Returns
>         [#3]  The ferror function returns nonzero if and only if the
>         error indicator is set for stream.
Oh! I did not know about that. Thanks a lot. I wonder just how much of
my C knowledge is wrong.
Regardless, the OP should still use both feof and ferror to find out
which happened when getc returned EOF.
0
vippstar (1211)
5/19/2008 5:02:44 PM
On May 19, 10:02 pm, vipps...@gmail.com wrote:

> Oh! I did not know about that. Thanks a lot. I wonder just how much of
> my C knowledge is wrong.
> Regardless, the OP should still use both feof and ferror to find out
> which happened when getc returned EOF.

where did getc come into picture ? i guess its a part of fgets
implementation ?
0
Broli00 (429)
5/19/2008 6:27:49 PM
pereges wrote:
> 
> I'm getting a warning on my linux gcc compiler:
> 
> /tmp/ccXgHa9s.o(.text+0x48): In function `main':
> : warning: the `gets' function is dangerous and should not be used.

And you should pay attention and not use it.  The simplest
replacement is ggets, which is written in standard C and you can
simply compile and link it to your program.  See:

  <http://cbfalconer.home.att.net/download/ggets.zip>

-- 
 [mail]: Chuck F (cbfalconer at maineline dot net) 
 [page]: <http://cbfalconer.home.att.net>
            Try the download section.


** Posted from http://www.teranews.com **
0
cbfalconer (19194)
5/19/2008 8:10:55 PM
Barry Schwarz wrote:
> pereges <Brol...@gmail.com> wrote:
> > Will this suffice:
> >
> > if(scanf("%s", zf_name) != 1)
>
> As coded, this is no better than fgets. ...

YM gets().

--
Peter
0
airia (1802)
5/19/2008 9:41:16 PM
Reply:

Similar Artilces:

gets gets
I'm a little surprised at this. In irb, I tried puts gets gets. Why? I don't know. but basically, gets gets, seems to almost act like a heredoc! myString = gets gets puts myString On Mar 26, 2007, at 3:17 AM, John Joyce wrote: > I'm a little surprised at this. > In irb, I tried puts gets gets. > Why? I don't know. > but basically, gets gets, seems to almost act like a heredoc! > myString = gets gets > puts myString It's not surprising at all. First, let's insert the parentheses so we can see it as Ruby does: puts(gets(gets())) Now we see th...

Return of gets gets
Not long ago I posted about gets gets I said it acted a bit like a Heredoc. I've since realized that it is actually more similar to readlines In fact, it behaves identically thus far. example: irb(main):004:0> lines = readlines ff fff akenll329 \n kls => ["ff\n", "fff\n", "akenll329\n", "\\n\n", "kls\n"] irb(main):005:0> puts lines ff fff akenll329 \n kls => nil irb(main):006:0> lines = gets gets fff ff ahoy \n lll ll => "ff\nahoy\n\\n\nlll ll\n" irb(main):007:0> puts lines ff ahoy \n lll ll => nil No...

how to get newline with gets?
Hello. I like the -nonewline option of puts, and wonder why there isn't a counter option in gets? The reason I need it is effectively I am doing this: set line [gets -withnewline stdin] if {[lindex $line end] eq "\r" } { # do something } if {[lindex $line end] eq "\n" } { # do something different } I guess without such an option I have to read byte-by-byte to achieve this, right? Thanks. On 5/11/11 1:21 PM, =E5=90=95=E9=9F=A6=E7=94=AB wrote: > Hello. I like the -nonewline option of puts, and wonder why there isn't= a > counter option in gets? &g...

Trying to get C++ to get a file and compare for logon and password validation
I am writing a project for a boat rental. I have done the shell to spring off to other modules to satisfy the menu. I am stuck on getting the right script for userid and password. I have a text file called users.txt I would like to be able to get the file, have it read by the program, stored in memmory, validate the entry to match what's on the file, then move on to do the same for the password entry. Then move on to the menu. Unless someone has a script that welcomes you, presents you with a logon screen then to the menu with shells to spring off to the modules to work with the items on ...

gets() fgets() with subdivide.c tilepack.c squarect.c
I am looking to use Ken Stephenson's CirclePack program (http://www.math.utk.edu/~kens/) with some tiling programs written by Cannon, Floyd, Parry. The programs I want to use are subdivide.c tilepack.c squarect.c . They are available from http://www.math.vt.edu/people/floyd/research/software/subdiv.html. I tried compiling them on my Redhat 9 box, eg cc subdivide.c. When I do so I get errors like "In function `Readtilingforvertex': : the `gets' function is dangerous and should not be used." I checked the FAQ and is says gets() is BAD and I should use fgets() instead....

apt-get install as root or su -c 'apt-get install' as user
apt-get install needs to be executed as root. What is the difference regarding security of my computer of the both possibilities? Tilo On 2008-01-12, Tilo Baumann <2007@eene.mine.nu> wrote: > > > > apt-get install needs to be executed as root. > > What is the difference regarding security of my computer of the both > possibilities? > When you use su -c or sudo, root privileges are dropped as soon as the command is complete. /var/log/auth.log shows what command was executed, instead of just showing when someone logged in as root. O...

How to get a handle to a JobObject without knowing its name, or how to get a JobObject's name in C?
My application is running in a job. I want to get a Handle to this Jobobjec= t using OpenJobObject so i can later use this handle. The problem is, that = i don't know the jobs name(because i didn't create it), and with passing NU= LL to the Job name it gives error 87 ( The parameter is incorrect ) back. This is how i tried it:=20 HANDLE handle =3D OpenJobObject( JOB_OBJECT_QUERY, FALSE, NULL ); if ( !handle ) printf( "\nError %d", GetLastError() ); else printf( "\nOK" ); I also found this on MSDN: An application cannot obtain a handle to the job= obje...

difference between chan gets / gets
Hi ! What difference between command chan gets and gets, chan puts and puts ? Many thanks ! serge_darin@mail.ru <serge_darin@mail.ru> wrote: > What difference between command chan gets and gets, chan puts and > puts ? They are supposed to be the same. puts is here for compatibility (and for those too lazy to write those extra 5 chars, like me), whereas chan is an attempt to have related functionality together in a single command. If you're old to tcl, you'll likely be used to top-level "puts", whereas if you're new to tcl, you're more likely to memo...

Get paid while you get online!!
I found a great Internet company - Cashfiesta.com - that has created a product everyone can benefit from. They pay you while you work or play on your computer. All you need to do is keep their software - the FiestaBar=99 - active while you are online. They even pay you when your friends are using their computers. Unlike other companies, Cashfiesta gives you control over how much money you earn. They have an individual payrate based on the number of Special Offers you sign up for. As some of these offers are free, you can increase your payrate up to 33 times without spending a penny. It's...

Get a Linux. Get a Mint!
https://www.youtube.com/watch?v=aufL76bXLAg ...

Get what everyone is getting!east
--0_.AEAC865_98_. Content-Type: text/html; Content-Transfer-Encoding: quoted-printable <html> <head> <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dwindows-= 1252"> <title>Easy DVD KIT</title> </head> <body bgcolor=3D"#336699"> <p align=3D"left"><b><font color=3D"#FFFF00" size=3D"5" face=3D"Verdana"><= i>Easy DVD KIT </font><font color=3D"#336699" size=3D"1" face=3D"Verdana">mon...

Where to get a compatibility list of C and C++?
Hi, all! I'm looking for a list of features that are supported in C but not supported in C++. I also need the complete list of language alterations from K&R C to C89 then to C99. Would anyone help? Thanks! Aladdin On 25 Jul 2005 18:44:11 -0700, "Aladdin" <buaa_aladdin@163.com> wrote in comp.lang.c: > Hi, all! > > I'm looking for a list of features that are supported in C but not > supported in C++. I also need the complete list of language alterations > from K&R C to C89 then to C99. > > Would anyone help? Thanks! > > Aladdin ...

Power C and Super C. Where to get them?
Hello, Does anyone know where to get those two C compilers? Are they in PD, freeware or abandonware category now? I will be grateful for all info: stankiewicz.piotr@interia.pl >>>>> "PS" == Piotr Stankiewicz <stankiewicz.piotr@interia.pl> writes: PS> Does anyone know where to get those two C compilers? Are they in PS> PD, freeware or abandonware category now? They're still commercial and copyrighted. They are also obsolete compared to cc65, http://www.cc65.org/ -- ___ . . . . . + . . o _|___|_ ...

Just getting started in C++, C+
Thanks in advance to all of you, Your recommendations: What kind of instruction and software are needed to learn and do useful programming using C+, C++ ? I would like to access and use the windows graphics environment. SRabin, > What kind of instruction and software are needed to learn and do useful > programming using C+, C++ ? There is nothing like C+. A good tutorial: http://www.cplusplus.com/doc/tutorial/ > I would like to access and use the windows graphics environment. Free: DevC++ (core c++, that black command line window) + WxWidgets (for graphical user interfaces) C...

get we get a fire started?
Hey all slow here these days....... A simple question for the gurus.........can I get hypervoxels to show up behind a transparent object? for example......bubbles inside a glass....shot from outside the glass........or are you forced to render the hypervoxels first and then overlay the glass later? I am stuck still using LW8.5 all thoughts welcome....just to get some discussion going hope everyone is well cheers Matthew ...

Get projects Get paid Learn while you earn Objective C and iPhone SDK www.convensysglobal.com/elearn
Hi This site is incredible. www.convensysglobal.com/elearn This is having sample codes active forums, extensive member support and anyone can start from basics. Easy to start tutorials. Be an active menber and get projects also. regards Babu Convensys ...

Why I get the warning
I got the warning: warning: Concatenation involves an empty array with an incorrect number of rows. This may not be allowed in a future release. I just do: a=[]; for i=1:10 a=[a,b]; % b is row vector whose length is variable end Hi, You should give b... With b=[1 2 3 4], no problem in my version. BTW you can do : a=repmat(b,1,10) to achieve the same yunzhi cheng wrote: > > > I got the warning: > > warning: Concatenation involves an empty array with an incorrect > number of rows. > This may not be allowed in a future release. > > I just do: > a=[]; > &g...

How to get signed zeros in C++/C?
I don't find how to express signed zeros in C++/C. Does anybody know what is the proper way to do so? Are they just -0.0 and +0.0? How to distinguish signed zeros from true zeros. http://en.wikipedia.org/wiki/Signed_zero Regard, Peng Peng Yu <pengyu.ut@gmail.com> writes: > I don't find how to express signed zeros in C++/C. Does anybody know > what is the proper way to do so? Are they just -0.0 and +0.0? How to > distinguish signed zeros from true zeros. > > http://en.wikipedia.org/wiki/Signed_zero AFAIK there is no literal for those. You need to ...

Getting parameters from the get method
Hello, I am pretty rusty with javascript and I am trying to make a webpage that will basically act as a wrapper from one webpage to another. What I mean by this is that I will hit this page like: webpage.htm?Param1=... and I will take the passed params and post them to another page. I have the post part working, but I was just wondering how I can use just Javascript and read those values passed to this webpage. Is this even possible? Thanks for all of your time. Matt "Matt" wrote > Hello, > > I am pretty rusty with javascript and I am trying to make a webpage > ...

get what is not equal in a.c to b.c
How come this one works SELECT DISTINCT a.d FROM a,b WHERE a.c NOT IN (SELECT b.c FROM b) but this one doesn't SELECT DISTINCT a.d,a.c FROM a LEFT JOIN b USING (c) WHERE a.c<>b.c I'm trying to get the rows in a.c that don't match b.c but the 2nd one should be faster. thanks, Janis TABLE A TABLE B col d col c col c ____________ ____________ 1 apple apple 2 banana kiwi 3 orange banana 4 grapefruit blackberry 5 cherry persimmon 6 N...

How do you get the username from the user_id (in c/c++)
I am making a list of users and the amount of space they are using on a device. I traverse the file system and get a list of filenames.. I use these filenames and do an fstat on each... fstat (on my MAC OS X) machine returns a structure that contains the filesize and also the user_id. (This is a c program I'm writing.) My question is how do I convert the user_id into the users name? (which should be a null terminated string.) What is the function call? TIA. B. On Fri, 10 Dec 2004, JustSomeGuy wrote: > My question is how do I convert the user_id into the users name? > (which s...

i getting this warning
mysql_fetch_row(): supplied argument is not a valid MySQL result below my code: <?php $qs=$_REQUEST['id']; mysql_connect("localhost","root",""); mysql_select_db("test"); $data=mysql_query("select * from tbl_porduct where pid=$qs"); $rec=mysql_fetch_row($data); $pname=$rec[1]; $price=$rec[3]; $sid=session_id(); mysql_query("insert into tbl_spro values('$sid','$pname','$price')"); ?> sri kanth wrote: > mysql_fetch_row(): supplied argument is not a valid MySQL result > below my code: > <...

Get(RecordNumber) = Get(RecordID)
Tried removing all indexing from all fields in my table but to no avail...the equation in the subject persists. Using Advanced 10.0v1. Any clues? I need the record number in the current (sorted) found set to be the value in a calculation (number) field. How is this done? TIA, Tim On Jun 19, 10:53=A0am, tim <tim.ruc...@gmail.com> wrote: > Tried removing all indexing from all fields in my table but to no > avail...the equation in the subject persists. =A0Using Advanced 10.0v1. > > Any clues? =A0I need the record number in the current (sorted) found set > to be the val...

GET, GET# and end of files
This is something I tripped over yesterday. Many of my BASIC programs have the following structure: 10 open source and target files 100 clear buffer contents 200 input from a source file, process and store data in the buffer The above step is repeated while space in the buffer is available 300 output data to a target file when the buffer is full. continue at lines 100 to 300 until all data in the source file has been processed. 400 endjob processing when an end of the source file is detected. Most programmers begin line 200 with code that looks like ...

Web resources about - getting a warning about gets - comp.lang.c

Will Taylor Swift Be Seen With Boyfriend Calvin Harris During The Grammys? Plus, How Did He Handle Kanye ...
Taylor Swift had a rough week. As she prepared to take the stage during tonight’s Grammy Awards in Los Angeles, she was viciously dissed by Kanye ...

Donald Trump, Code Pink Republican
The WEEKLY STANDARD Podcast with staff writer Michael Warren on Donald Trump's recent 9/11 comments, South Carolina, and more. This podcast ...

Watch: BJP leader O P Sharma assaults 'CPI leader' outside Patiala House court
JNUSU president Kanhaiya’s arrest had triggered widespread outrage among students and teachers and drawn severe criticism from non-BJP political ...

Kim Kardashian Hints At Divorce With Cryptic Valentine’s Day Video: ‘Hard To Love A Girl Like Me’
Are Kim Kardashian and Kanye West headed for divorce? While the famous pair, who are the parents of 2-year-old North West and 2-month-old Saint ...

NBA All-Star Game Ratings on TNT and TBS Up in Kobe Bryant’s Final Appearance
Kobe Bryant’s 18th and final appearance in the NBA All-Star Game helped boost viewership for this year’s event, which was at its highest level ...

U.N. Says 50 Were Killed in Strikes on Four Syria Hospitals
Officials at the United Nations and Doctors Without Borders said missile strikes in north Syria hit four facilities, with children among the ...

These Are Almost Certainly Samsung’s Next Galaxy Phones: Galaxy S7 and S7 Edge Leak All Over
We’re about a week out from Mobile World Congress, the big trade show where just about everyone-but-Apple traditionally shows off their new flagship ...

The Walking Dead Recap: The Convenient Rocket Launcher
Hello, and welcome back to The Walking Dead Chitty Chat Club! Did you happen to catch last night's mid-season premiere of The Walking Dead ? ...

‘Bitten’ Star Laura Vandervoort and Creator Daegan Fryklind Talk Season 3 Premiere, Series’ Future
As the world’s only female werewolf in a species full of men, “Bitten’s” Elena Michaels (Laura Vandervoort) is used to having the odds stacked ...

New Lumia 650 looks nice but misses Windows 10 Mobile’s best feature
(credit: Microsoft) Microsoft has announced a new phone running Windows: the Lumia 650. As its name numerically implies, this phone sits closer ...

Resources last updated: 2/15/2016 11:58:53 PM