- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 1401 Articles for C
26K+ Views
Pointer to structure holds the add of the entire structure.It is used to create complex data structures such as linked lists, trees, graphs, and so on.The members of the structure can be accessed using a special operator called as an arrow operator ( -> ).DeclarationFollowing is the declaration for pointers to structures in C programming −struct tagname *ptr;For example − struct student *s −AccessingIt is explained below how to access the pointers to structures.Ptr-> membername;For example − s->sno, s->sname, s->marks;Example ProgramThe following program shows the usage of pointers to structures −#include struct student{ int sno; char sname[30]; ... Read More
4K+ Views
An array of structure in C programming is a collection of different datatype variables, grouped together under a single name.General form of structure declarationThe structural declaration is as follows −struct tagname{ datatype member1; datatype member2; datatype member n; };Here, struct is the keyword.tagname specifies the name of structure.member1, member2 specifies the data items that make up structure.ExampleThe following example shows the usage of array within a structure in C programming −struct book{ int pages; char author [30]; float price; };ExampleFollowing is the C program to demonstrate the use of an array within a structure ... Read More
43K+ Views
An array of structure in C programming is a collection of different datatype variables, grouped together under a single name.General form of structure declarationThe structural declaration is as follows −struct tagname{ datatype member1; datatype member2; datatype member n; };Here, struct is the keyword tagname specifies name of structure member1, member2 specifies the data items that make up structure.ExampleThe following example shows the usage of array of structures in C programming −struct book{ int pages; char author [30]; float price; };Array of structuresThe most common use of structure in C programming is an ... Read More
1K+ Views
An array of characters is called a string.DeclarationThe syntax for declaring an array is as follows −char stringname [size];For example − char string[50]; string of length 50 charactersInitializationUsing single character constant −char string[10] = { ‘H’, ‘e’, ‘l’, ‘l’, ‘o’ ,‘\0’}Using string constants −char string[10] = "Hello":;Accessing − There is a control string "%s" used for accessing the string till it encounters ‘\0’.Now, let us understand what are the arrays of pointers in C programming language.Arrays of pointers: (to strings)It is an array whose elements are ptrs to the base add of the string.It is declared and initialized as follows ... Read More
788 Views
The C library function char *strstr(const char *haystack, const char *needle) function finds the first occurrence of the substring needle in the string haystack. The terminating '\0' characters are not compared.An array of characters is called a string.DeclarationThe syntax for declaring an array is as follows −char stringname [size];For example − char string[50]; string of length 50 charactersInitializationUsing single character constant −char string[10] = { ‘H’, ‘e’, ‘l’, ‘l’, ‘o’ ,‘\0’}Using string constants −char string[10] = "Hello":;Accessing − There is a control string "%s" used for accessing the string till it encounters ‘\0’.The strstr() FunctionIt is used to search whether ... Read More
3K+ Views
The C library function int strncmp(const char *str1, const char *str2, size_t n) compares at most the first n bytes of str1 and str2.An array of characters is called a string.DeclarationThe syntax for declaring an array is as follows −char stringname [size];For example − char string[50]; string of length 50 charactersInitializationUsing single character constant −char string[10] = { ‘H’, ‘e’, ‘l’, ‘l’, ‘o’ ,‘\0’}Using string constants −char string[10] = "Hello":;Accessing − There is a control string "%s" used for accessing the string till it encounters ‘\0’.The strncmp ( ) FunctionThis function is used for comparing first ‘n’ characters of 2 ... Read More
593 Views
The C library function int strcmp(const char *str1, const char *str2) compares the string pointed to, by str1 to the string pointed to by str2.An array of characters is called a string.DeclarationFollowing is the declaration for an array −char stringname [size];For example − char string[50]; string of length 50 charactersInitializationUsing single character constant −char string[10] = { ‘H’, ‘e’, ‘l’, ‘l’, ‘o’ ,‘\0’}Using string constants −char string[10] = "Hello":;Accessing − There is a control string "%s" used for accessing the string till it encounters ‘\0’.The strcmp() functionThis function compares two strings.It returns the ASCII difference of the first two non ... Read More
1K+ Views
The C library function char *strncat(char *dest, const char *src, size_t n) appends the string pointed to by src to the end of the string pointed to by dest up to n characters long.An array of characters is called a string.DeclarationFollowing is the declaration for an array −char stringname [size];For example: char string[50]; string of length 50 charactersInitializationUsing single character constant −char string[10] = { ‘H’, ‘e’, ‘l’, ‘l’, ‘o’ ,‘\0’}Using string constants −char string[10] = "Hello":;Accessing − There is a control string "%s" used for accessing the string till it encounters ‘\0’.The strncat( ) functionThis is used for combining ... Read More
1K+ Views
The C library function char *strcat(char *dest, const char *src) appends the string pointed to by src to the end of the string pointed to by dest.An array of characters is called a string.DeclarationFollowing is the declaration for an array −char stringname [size];For example − char string[50]; string of length 50 charactersInitializationUsing single character constant −char string[10] = { ‘H’, ‘e’, ‘l’, ‘l’, ‘o’ ,‘\0’}Using string constants −char string[10] = "Hello":;Accessing − There is a control string "%s" used for accessing the string till it encounters ‘\0’.The strcat( ) functionThis is used for combining or concatenating two strings.The length of ... Read More
633 Views
The C library function char *strcpy(char *dest, const char *src) copies the string pointed to, by src to dest.An array of characters is called a string.DeclarationFollowing is the declaration for an arraychar stringname [size];For example − char string[50]; string of length 50 charactersInitializationUsing single character constant −char string[10] = { ‘H’, ‘e’, ‘l’, ‘l’, ‘o’ ,‘\0’}Using string constants −char string[10] = "Hello":;Accessing − There is a control string "%s" used for accessing the string till it encounters ‘\0’The strcpy ( ) functionThis function is used for copying source string into destination string.The length of the destination string is greater than ... Read More