textMagician/textmagicscripts/space-to-snake/space-to-snake.c
2024-07-31 23:12:49 +02:00

40 lines
868 B
C

/*
* This simple program is created by Roland Hollós (hollorol@rolandhollos.net)
* It is works like this:
* ez itt egy nagyon hosszu valtozo == ez_itt_egy_nagyon_hosszu_valtozo_
*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX_LINE_LEN 10000
int
main()
{
char s[MAX_LINE_LEN];
char out[MAX_LINE_LEN];
while(fgets(s, MAX_LINE_LEN, stdin) != NULL){
int string_length = strlen(s);
for(int i = 0; i < string_length; ++i)
{
/* if((s[i] >= 65) && (s[i] <= 90)) */
if(s[i] == ' '){
out[i] = '_';
continue;
}
if((s[i] >= 65) && (s[i] <= 90))
{
out[i] = s[i] + 32;
}
out[i] = s[i];
}
out[string_length] = '\0';
printf("%s", out);
}
return 0;
}