Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int str_len(char str[]) {
- int count = 0;
- for (int i = 0; str[i] != '\0'; i++) {
- count = count + 1;
- }
- return count;
- }
- void one_word_per_line(char str[]) {
- for (int i = 0; str[i] != '\0'; i++) {
- if (str[i] == ' ') {
- printf("\n");
- } else {
- printf("%c", str[i]);
- }
- }
- printf("\n");
- }
- int main() {
- one_word_per_line("the quick brown fox");
- // the
- // quick
- // brown
- // fox
- //char str[6] = {'a', 'b', 'c', 'd', 'e', '\0'};
- char str[10] = "abcde";
- printf("%s\n", str);
- printf("%d\n", str_len(str));
- char ch = 'a';
- printf("%c\n", ch);
- printf("%i\n", ch);
- printf("%c\n", ch + 5);
- printf("%c\n", 64);
- char chs[5] = {'a', 'b', 'c', 'd', 'e'};
- for (int i = 0; i < 5; i++) {
- printf("%c ", chs[i]);
- }
- printf("\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement