AntonioVillanueva

Elimina espacios al inicio en lenguaje C / Supprimer les espaces de début en langage C

Jan 11th, 2021 (edited)
483
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.59 KB | None | 0 0
  1. //https://wandbox.org/permlink/Ljstos87j6BjbZia
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. /*-------------------------------------------------------------------------------*/
  6. int main( int argc, char **argv )
  7. {  
  8.     char buf[]="       Icaro es hijo del arquitecto Dédalo, constructor del laberinto de Creta,";
  9.     char *pt;//Puntero a un char
  10.    
  11.     while (  buf[0] <=32 && (pt=strchr(buf,32)) !=NULL )//Puntero sobre la primera ocurrencia de 32 ESPACIO
  12.         {sprintf (buf,"%s",pt+1) ;}//Copia del puntero en adelante
  13.  
  14.     printf ("%s\n",buf);
  15.    
  16.     return 0;
  17. }
  18.  
Add Comment
Please, Sign In to add comment