This code will show us how pointer are so much useful for us.
We can do anything using pointer.
Note: Just copy and paste this code in either Turbo C++, or Dev C, environment, then compile and execute the code.
This code will show us how pointer are so much useful for us.
We can do anything using pointer.
Note: Just copy and paste this code in either Turbo C++, or Dev C, environment, then compile and execute the code.
#include<stdio.h>
#include<string.h>
int main()
{
// create a string
char str[] = "C for Computer";
// get length of string using strlen() function
int length = strlen(str);
int i = 0;
int j = 0;
for(i=0;i<length;i++)
{
// here "str" means the base address of string
// so value of 'i' will move the pointer of string to next index
printf("%s",str+i);
printf("\n");
}
for(j=i;j>=0;j--)
{
// here "str" means the base address of string
// so value of 'j' will move the pointer of string to previous index
printf("%s",str+j);
printf("\n");
}
return 0;
}
We can do anything using pointer.
Note: Just copy and paste this code in either Turbo C++, or Dev C, environment, then compile and execute the code.
This code will show us how pointer are so much useful for us.
We can do anything using pointer.
Note: Just copy and paste this code in either Turbo C++, or Dev C, environment, then compile and execute the code.
#include<stdio.h>
#include<string.h>
int main()
{
// create a string
char str[] = "C for Computer";
// get length of string using strlen() function
int length = strlen(str);
int i = 0;
int j = 0;
for(i=0;i<length;i++)
{
// here "str" means the base address of string
// so value of 'i' will move the pointer of string to next index
printf("%s",str+i);
printf("\n");
}
for(j=i;j>=0;j--)
{
// here "str" means the base address of string
// so value of 'j' will move the pointer of string to previous index
printf("%s",str+j);
printf("\n");
}
return 0;
}
No comments:
Post a Comment