initial commit
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
DEST=$(HOME)/.local/bin
|
||||
SRC=space-to-snake.c
|
||||
OUT=space_to_snake
|
||||
|
||||
../$(OUT): $(SRC)
|
||||
gcc -pedantic -Wall -Wextra $(SRC) -o ../$(OUT)
|
||||
install:
|
||||
cp ../$(OUT) $(DEST)
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
Reference in New Issue
Block a user