fork download
  1. #include <stdio.h>
  2.  
  3. void removerEspacosEsquerda(char string[]) {
  4. int cont = 0;
  5. for (int i = 0; string[i] != '\0'; i++, cont++) {
  6. if (string[i] == ' ') cont--;
  7. else string[cont] = string[i];
  8. }
  9. string[cont] = '\0';
  10. }
  11.  
  12. int main() {
  13. char string[] = " teste";
  14. removerEspacosEsquerda(string);
  15. printf("%s", string);
  16. }
  17.  
  18. //https://pt.stackoverflow.com/q/344240/101
Success #stdin #stdout 0s 9424KB
stdin
Standard input is empty
stdout
teste