meter espacios en cadena c 1

meter espacios en cadena c

cambiar %s por %[^\n] y funcionarán los espacios

Ejemplo:

char variable[50];
printf("Ingresa el valor:\n");
scanf("%[^\n]", variable);

Here is what the above code is Doing:
1. The first %s is replaced by the first argument which is the string “Hello”.
2. The second %s is replaced by the second argument which is the string “World”.
3. The third %d is replaced by the third argument which is the integer 42.
4. The fourth %f is replaced by the fourth argument which is the float 99.99.

Similar Posts