Sunday, 6 June 2021

Pointers and Strings in C

Strings are treated like character arrays and therefore, they are declared and initialized as follows.

char s1[5]="hello"

A character array can also be declared suing pointers as

char *s1="hell";

The pointer "s1" points" to first element in the array. The array name is first element address.


 

Example:


void main()
{
char *s1="hello";
printf("%s",s1);
getch();
}


0 comments:

Post a Comment

Note: only a member of this blog may post a comment.

Find Us On Facebook

Computer Basics

More

C Programming

More

Java Tutorial

More

Data Structures

More

MS Office

More

Database Management

More
Top