Embedded world

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;
}



Sunday, June 3, 2018

Printing The Array Element of 1-D Array

Array-Array is a collection of same type of data like (int, char,Float).Array is stored in Continuous Memory Location .

For Example:

int boy[5]={11,12,13,14,15,16};

In this Statement boy is an array consisting of 5 member/Element.Like

boy[0]=11;
boy[1]=12;
boy[2]=13;
boy[3]=14;
boy[4]=15;
boy[5]=16;

Note :Array index start with 0 ,So Array index always  one less than Size of array.

//Program to Print Element of Array

#include <stdio.h>

int main()
{
int arr[6]={11,12,13,14,15,16};
    int i;
   
    for(i=0;i<6;i++)
    {
     
       printf("%d\n",arr[i]);
     
    }
return 0;

}




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...