C language how to iterate through characters in a string

C language how to iterate through characters in a string

How to read characters in a string in C language.
In C, strings are represented using character arrays, and the last character is '\0';

/*
Example: read character from a string in C language
*/

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char const *argv[]) {

    char arr[100] =  {'l','a','u','t','t','u','r','i','.','c','o','m','\0'};

	// iterate characters in string
    for(int i=0; arr[i] != '\0'; ++i)
    {
        printf("%c\n",arr[i]);
    }
    return 0;
}
Source:w‮ww‬.lautturi.com
Created Time:2017-08-29 05:55:32  Author:lautturi