A C program to copy the contents of one string to another using a pointer method is: #include #include #include #define length 50 void main() { char *s1,*s2,c; int i=0; clrscr(); s1=(char*)malloc(length*sizeof(char)); s2=(char*)malloc(length*sizeof(char)); printf(“enter stringn”); gets(s1); while((c=*(s1+i))!=”) { s2[i]=c; i++; } s2[i]=”; printf(“Copied string isn”); printf(“%s”,s2); getch(); }
C Programming
How to display the value of an integer variable through pointer ?
Accessing the value of an integer through pointer. A pointer is a variable which contains the address in memory of another variable. We can have a pointer to any variable type. The unary or monadic operator & gives the “address of a variable”. The indirection or dereference operator * gives the “contents of an object pointed to by […]
Pointer to structure in C
How to use a pointer to structure in C Programming? When pointer to structure is incremented then the pointer points to the next block of memory. As for example struct rec { int a; char b[10], *c; }; main() { struct rec *obj; obj=(struct rec *)malloc(sizeof(struct rec)); obj->a=10; strcpy(obj->b, “XYZ”); strcpy(obj->c, “ABC”); printf (“n%dt%st%s”,obj->a, obj->b, […]
Pointer in C Hackerrank Solution
Pointer in C Hancerrank Solution In this Pointer in C Programming Tutorial at first we will learn about basic concepts of pointer after that we will see some pointer in c hackerrank solution for the practice of computer science students. Frequently asked Questions Some frequently asked questions from pointer in c programming are given below […]
Structure in C Programming
Structure in C Programming Structure in C Programming is a collection of variables of different types under the same name. In simple words, structure in c programming is used to store different types of data elements. In this tutorial, we will learn about structure in c programming. We will learn the following concepts about structure in C […]
C Programming Interview Questions – Part 3
“C programming language is a very important programming language for freshers from technical interview point of view. Sometime interviewers ask some tricky questions. Interviewer also asks students to write some well known program in C programming language. In previous post I have posted some questions from C programming language. In this post again I am […]
Short Interview Questions from C Programming
” I am listing some of the important questions from C programming Language which are mostly asked during Technical interview for freshers. I hope all the students will like these questions and also suggest some other typical questions in comment.” […]
Basic Questions from C Programming !
” I am listing some of the important questions from C programming Language which are mostly asked during Technical interview for freshers. I hope all the students will like these questions and also suggest some other typical questions in comment.” […]
Objective Questions from C Programming Language
C is a common Programming language which is used for software development especially for system software. Objective from C programming language are generally asked in every written test related to computer job.In this post ,I am presenting some objective questions from C Programming.Try to attempt these related to computer job. objective Questions from C Programming 1.struct […]