Untitled

 avatar
unknown
plain_text
3 years ago
793 B
5
Indexable
#include <stdio.h>

#define SIZE 10  // in case we want a word in different size in the future, 
// we need to change only this value, and the program will work just fine

int main()
{
    int i = 0; // a counter

    // un-comment the next lines to read a word from the user
    /* 
    printf("enter string \n");
    char word[SIZE] = {}; // an array of chars, in the length of SIZE, initialized to '\0' s
    scanf("%s", word); // read a word
    */
    
    
    char word[SIZE] = {'c', 'r', 'n', 'b', 'r', 'i', 's'};
    
    while (i < SIZE - 1){ // didn't reach the end of the array
        if (word[i] == '\0') // found a '\0'
            word[i] = '!'; // replace it with '!'
        i++; // increment counter
    }
    
    printf("%s", word); // print the word
    
    return 0;
}
Editor is loading...