🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.os.linux.programacion
Article #12024

Re: atoi asta los co.....

#12024
From: Ignacio Arenaza
Date: Mon, 10 Sep 2001 21:34
56 lines
2368 bytes
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

>>>>> "Angel" == �ngel Su�rez Rivero <srangel@teleline.es> writes:

    Angel> Hola, alguien sabe como usar las funciones atoi y
    Angel> strtol. Pos mas que leo las man, menos entiendo lo que
    Angel> hacen. Yo cre�a que ambas devolvian un entero equivalente
    Angel> al tama�o de una cadena o el indice de la misma, pero esto
    Angel> no devuelve mas que 0 ?:((.  

Ahi va un ejemplillo de como funciona:

Script started on Mon Sep 10 23:29:23 2001
bash-2.05$ cat atoi.c
#include <stdio.h>
#include <stdlib.h>

int main (void)
{
	char linea[255+1];
	int	valor;

	fgets (linea, 255, stdin);
	valor = atoi (linea);
	printf ("%d\n", valor);
	return 0;
}
bash-2.05$ gcc -Wall -pedantic atoi.c -o atoi
bash-2.05$ /atoi
123
123
bash-2.05$ ./atoi
asdf
0
bash-2.05$ ./atoi
123a
123
bash-2.05$ exit
Script done on Mon Sep 10 23:33:00 2001

Saludos. I�aki.


- -- 
  Get PGP/GPG Keys at  http://www.escomposlinux.org/iarenaza/pgpkey.html
  I use free software / Yo uso software libre

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Processed by Mailcrypt and GPG

iD8DBQE7nTIBZXLnGT1HLgcRArx0AJ4gJAgKXgCQLM1CXyPrzK4Elb5eOwCeITWY
I5WibhAXKQcVzzzfwFYkRGw=
=IJpB
-----END PGP SIGNATURE-----
Technical Details
Message-ID: <871yleu3um.fsf@eb2ebu.ampr.org>
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!newsfeeds.belnet.be!news.belnet.be!opentransit.net!newsfeed.comtenidos.com!newsfeeder.wanadoo.es!eb2ebu.ampr.org!not-for-mail
References: <3B9D1E2B.E93F13C2@teleline.es>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: f86c8,7199466e0fea4eef
X-Google-Attributes: gidf86c8,public
X-Google-ArrivalTime: 2001-09-10 16:01:02 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!newsfeeds.belnet.be!news.belnet.be!opentransit.net!newsfeed.comtenidos.com!newsfeeder.wanadoo.es!eb2ebu.ampr.org!not-for-mail
From: Ignacio Arenaza <iarenaza@eb2ebu.ampr.org>
Newsgroups: es.comp.os.linux.programacion
Subject: Re: atoi asta los co.....
Date: 10 Sep 2001 23:34:57 +0200
Organization: Servidor NNTP de eb2ebu.ampr.org
Lines: 56
Message-ID: <871yleu3um.fsf@eb2ebu.ampr.org>
References: <3B9D1E2B.E93F13C2@teleline.es>
NNTP-Posting-Host: 62-36-89-41.dialup.uni2.es
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: news.wanadoo.es 1000162213 1174 62.36.89.41 (10 Sep 2001 22:50:13 GMT)
X-Complaints-To: usenet@wanadoo.es
NNTP-Posting-Date: Mon, 10 Sep 2001 22:50:13 +0000 (UTC)
User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7