39 lines
968 B
C
39 lines
968 B
C
#include <stdio.h>
|
|
#include <string.h>
|
|
#include "stringy.h"
|
|
|
|
int meno() {
|
|
char str[11];
|
|
char strkopia[25];
|
|
printf("Zadaj meno(max 10 znakov):");
|
|
scanf("%10s", str);
|
|
strcpy(strkopia, str);
|
|
char *acko = strchr(str, 'a');
|
|
int poloha_acka = -1;
|
|
if (acko) {
|
|
poloha_acka = acko - str;
|
|
}
|
|
strcat(strkopia, " je tvoje meno");
|
|
int dlzka = strlen(str);
|
|
printf("Kópia: %s, meno: %s ,dĺžka: %d, 'a' sa nachádza na: %d mieste v zadanom texte", strkopia, str, dlzka, poloha_acka);
|
|
|
|
}
|
|
|
|
int stringy() {
|
|
char str[21];
|
|
printf("Zadaj vetu(max 20 znakov):");
|
|
fgets(str, 20, stdin);
|
|
printf("Zadaj znak:");
|
|
char needle = getchar();
|
|
int strlocation = 0;
|
|
int needlecount = 0;
|
|
while (str[strlocation] != 0){
|
|
if(str[strlocation] == needle){
|
|
needlecount++;
|
|
}
|
|
strlocation++;
|
|
}
|
|
printf("%c sa v %s nachádza %d krát.", needle, str, needlecount);
|
|
|
|
return 0;
|
|
} |