
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 1339 Articles for C

5K+ Views
I/O refers to the input - output functions in C language.High level I/OThese are easily understood by human beingsThe advantage is portability.Low level I/OThese are easily understood by computer.The advantage is that execution time is less.The disadvantage is that Non portability.High level I/O FunctionsThe high level input - output (I/O) functions are explained below −FunctionDescriptionfprintf ( )write data into a filefscanf ( )read data from a fileputc ( )/ fputc()write a character into a filegetc ( ) /fgetc()read a character from a fileputw ( )write a number into a filegetw ( )read number from a filefputs ( )write a string ... Read More

679 Views
If the structure is nested inside a union, it is called as a union of structures. There is a possibility to create a union inside a structure in C programming language.ExampleFollowing is the C program for union of structures −#include struct x { int a; float b; }; union z{ struct x s; }; main ( ){ union z u; u.s.a = 10; u.s.b = 30.5; printf("a=%d", u.s.a); printf("b=%f", u.s.b); getch ( ); }OutputWhen the above program is executed, it produces the following result −a= 10 b = 30.5ExampleGiven below is ... Read More

2K+ Views
The differences between structures and unions in C language are explained below −S.NoStructureUnion1DefinitionStructure is heterogenous collection of data items grouped together under a single nameDefinitionA union is a memory location that is shared by several variables of different datatypes.2Syntax;struct tagname{ datatype member1; datatype member2; ---- ---- ---- };Syntax;union tagname{ datatype member1; datatype member2; ---- ---- ---- };3Eg;struct sample{ int a; float b; char c; };Eg;union sample{ int a; float b; char c; };4keyword − structkeyword − union5Memory allocationMemory allocation67Memory allocated is the sum of ... Read More

175 Views
Pointer to structure holds the address of an entire structure.Mainly, these are used to create the complex data structures such as linked lists, trees, graphs and so on.The members of the structure can be accessed by using a special operator called arrow operator ( -> ).DeclarationFollowing is the declaration for pointer to structure −struct tagname *ptr;For example, struct student *s;AccessingYou can access pointer to structure by using the following −Ptr-> membername;For example, s->sno, s->sname, s->marks;ExampleFollowing is the C program of the pointer structures −#include struct student{ int sno; char sname[30]; float marks; }; main ( ){ ... Read More

577 Views
Passing the address of structure as an argument to function −The Address of the structure is passed as an argument to the function.It is collected in a pointer to structure in function header.AdvantagesNo wastage of memory as there is no need of creating a copy againNo need of returning the values back as the function can access indirectly the entire structure and work on it.Example#include struct date{ int day; int mon; int yr; }; main (){ struct date d= {02, 01, 2010}; display (&d); getch (); } display (struct date *dt){ printf("day = ... Read More

977 Views
Passing individual members as arguments to function −Each member is passed as an argument in the function call.They are collected independently in ordinary variables in function header.Example#include //Declaring structure// struct student{ int s1,s2,s3; }s[5]; //Declaring and returning Function// void addition(int a,int b,int c){ //Declaring sum variable and For loop variable// int i,sum; //Arithmetic Operation// for(i=1;i

563 Views
Typedef‘C’ allows to define new datatype names using the ‘typedef’ keyword. Using ‘typedef’, we cannot create a new datatype but define a new name for already existing type.Syntaxtypedef datatype newname;Exampletypedef int bhanu; int a; bhanu a; %dThis statement tells the compiler to recognize ‘bhanu’ as another name for ‘int’.‘bhanu’ is used to create another variable ‘a’ .‘bhanu a ‘declares ‘a’ as a variable of type ‘int’.Example#include main (){ typedef int hours; hours h; //int h; clrscr (); printf("Enter hours”); scanf ("%d”, &h); printf("Minutes =%d”, h*60); printf("Seconds = %d”, h*60*60); getch (); ... Read More

66K+ Views
Using strrev() functionThe function is used for reversing a string.The reversed string will be stored in the same string.Syntaxstrrev (string)Before working on reversing the string without using function, let’s have a look on how to reverse a string using string function strrev(), so that we can easily find the difference and gets clarity on the concept −Example#include main (){ char a[50] ; clrscr(); printf (“enter a string”); gets (a); strrev (a); printf(“reversed string = %s”, a) getch (); }Outputenter a string Hello reversed string = olleHWithout using strrev() functionNow let’s see the program ... Read More

10K+ Views
Before going to know about how to convert upper case to lower case letters without string convert function.Let us have a look on program to convert upper to lower using convert function, then you will get a clarity on what we are doing in the program −Example#include #include int main(){ char string[50]; printf("enter a string to convert to lower case"); gets(string); /reading the string printf("The string in lower case: %s", strlwr(string)); //strlwr converts all upper to lower return 0; }Outputenter a string to convert to lower case CProgramming LangUage The string ... Read More

1K+ Views
ProblemWhat do you mean by String to number and number to string conversion in C programming language?SolutionThere are two functions available for conversion. They are −sscanf() − convert string to numbersprintf () − used for converting number to stringString to number conversionWe can convert string to number using the sscanf() function −Syntaxsscanf (string name, “control string”, variable list)Example#include main (){ char a[20] = “02 01 2010”; int day, mon, yr; clrscr(); sscanf (a, “%d%d %d”, &day, &mon, &yr); printf ( “Day =%d”, day); printf ( “Month = %d”, mon); printf ( “Year = ... Read More