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.

Machine Learning

More

Advertisement

Java Tutorial

More

UGC NET CS TUTORIAL

MFCS
COA
PL-CG
DBMS
OPERATING SYSTEM
SOFTWARE ENG
DSA
TOC-CD
ARTIFICIAL INT

C Programming

More

Python Tutorial

More

Data Structures

More

computer Organization

More
Top