Embedded,C Programming,C,Linux

Monday, June 4, 2018

Printing a String in C


// Sample Program using strlen() function

#include<stdio.h>

#include <stdio.h>
#include <string.h>

int main()
{
char name[10];
printf("Enter the String");
scanf("%s",name);
printf("you have Entered %s\n",name);
printf("lenght of string = %d",strlen(name));
return 0;
}


// STRING LENGHT WITHOUT FUNCTION

#include <stdio.h>

int main()
{
    char str_buff[20];
    int count =0;
    printf("Enter your string");
    gets(str_buff);
    while(str_buff[count]!='\0')
    count++;
    printf("Lenght of string is %d",count);
    return 0;
}



No comments:

Post a Comment

Finding COM PORT in ubuntu

 Hello ,In this post we see how to find COM port/Serial port in Ubuntu. Items Required 1.Usb to TTL cable  Step 1: Finding COM Port in Compu...