Read string from user using C Functions

C Programming Language String functions in C (Article) String functions in C (Program)

258

Program:

#include<stdio.h>
#include<string.h>
int main()
{
int i;

char arrayName[100];
gets(arrayName);

   for(i = 0; arrayName[i] != 0; i++)
    {
    printf("%c", arrayName[i]);
    }
}

Output:

Hello
Hello

Explanation:

You can user this code for the same program

Note: Though, gets() and puts() function handle strings, both these functions are defined in "string.h" header file.



#include<stdio.h>
#include<string.h>
int main()
{
int i;
char arrayName[100];
gets(arrayName);
puts(arrayName);
}



This Particular section is dedicated to Programs only. If you want learn more about C Programming Language. Then you can visit below links to get more depth on this subject.