Linux-Bulgaria.ORG
навигация

 

начало

пощенски списък

архив на групата

семинари ...

документи

как да ...

 

 

Предишно писмо Следващо писмо Предишно по тема Следващо по тема По Дата По тема (thread)

Re: lug-bg: grep ? cat? tail?


  • Subject: Re: lug-bg: grep ? cat? tail?
  • From: whitefang@xxxxxx ( )
  • Date: Fri, 17 May 2002 17:42:51 +0300



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Friday 17 May 2002 16:02, you wrote:
> > Ako nqkoi sega natrqska edin parser na C kolekciqta funkcionalni resheniq
> > shte e pylna :)
>
> /*
> WARNING!!! Highly insecure&&exploitable code
> */
>
> #include <stdio.h>
> #include <errno.h>
>
> int main(int argc,char *argv[])
> {
>   FILE *f;
>   int s,e,c=0;
>   char l[100000];
>
>   if (argc!=4)
>   {
>     printf("Usage: %s <filename> <start> <end>\n",argv[0]);
>     return 1;
>   }
>
>   if ((f=fopen(argv[1],"r"))==NULL) {perror("fopen()");return 1;}
>
>   sscanf(argv[2],"%d",&s);
>   sscanf(argv[3],"%d",&e);
>
>   while (fgets(l,100000,f))
>   {
>     c++;
>     if ((s<=c)&&(c<=e)) fputs(l,stdout);
>     if (c>e) break;
>   }
>
>   fclose(f);
>   return 0;
> }
>
>
> Tva go napisah za 5 minuti just for fun, znam che sigurno e bugavo :)
> Ama poneje kolegata otpravi predizvikatelstvo :)
> Moga i na C++ s iostreams da go napisha, ama aide tova niakoi drug :)
Samo 4e mernata edinica niama da e "lines" , a "words", zashtoto 
razdelitelite s koito raboti fgets() sa '\xd' '\x9' '\xa' i shpacia.
On GNU systems izpolzwai getline().
On non GNU systems:    fscanf(f,"%100000[^'\n']\n",l); 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.4 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE85Rbumx3uqe61brwRAiubAKCV//pYJiYY6gJoLzFp+LzsRPi7JACg0Bo6
p+rVWh9O/XWjc+GFcJLQBgA=
=A/U8
-----END PGP SIGNATURE-----
============================================================================
A mail-list of Linux Users Group - Bulgaria (bulgarian linuxers).
http://www.linux-bulgaria.org - Hosted by Internet Group Ltd. - Stara Zagora
To unsubscribe: http://www.linux-bulgaria.org/public/mail_list.html
============================================================================



 

наши приятели

 

линукс за българи
http://linux-bg.org

FSA-BG
http://fsa-bg.org

OpenFest
http://openfest.org

FreeBSD BG
http://bg-freebsd.org

KDE-BG
http://kde.fsa-bg.org/

Gnome-BG
http://gnome.cult.bg/

проект OpenFMI
http://openfmi.net

NetField Forum
http://netField.ludost.net/forum/

 

 

Linux-Bulgaria.ORG

Mailing list messages are © Copyright their authors.