SHARE
TWEET

Untitled

niqo1993 Nov 11th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     size_t k = atoi(argv[2]);
  2.     char* cadena = argv[1];
  3.     size_t n = 0;
  4.     char* cadena_aux;
  5.     aux = 0;
  6.     cola_t* cola = cola_crear();
  7.     char* buffer = NULL;
  8.     while(getline(&buffer,&n,archivo) > 0){
  9.         if (strstr(buffer,cadena) != NULL){
  10.             if (k == 0) printf("%s\n",buffer );
  11.             else if (k > 0){
  12.                 while (!cola_esta_vacia(cola)){
  13.                     cadena_aux = (char*)cola_desencolar(cola);
  14.                     printf("%s\n",cadena_aux );
  15.                     free(cadena_aux);
  16.                     aux--;
  17.                 }
  18.                 printf("%s\n",buffer );
  19.             }
  20.         }
  21.         else{
  22.             if (k == aux){
  23.                 cadena_aux = (char*)cola_desencolar(cola);
  24.                 free(cadena_aux);
  25.             }
  26.             if (k > 0){
  27.                 cola_encolar(cola, (void*)buffer);
  28.                 aux++;
  29.             }
  30.         }
  31.         //free(buffer);
  32.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top