C Program to demonstrate the strstr function.

C Program to demonstrate the strstr function.
strstr function finds the substring in a string. strstr() returns pointer of the first occurrence of the string other wise it returns the null pointer is returned.
In this program strstr returns a pointer into ‘string’ if ‘test’ is found, if not found, NULL is returned. Read more about C Programming Language .

/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/


#include <stdio.h>
#include <string.h>

main()
{
char string[]="string to search";
char test[]="sear";
if (strstr(string, test)) puts("String found");

}
Read more c programs 
C Basic
C Strings

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

To browse more C Programs visit this link
(c) www.c-program-example.com

C Program to demonstrate strpbrk function.

Write C programt to demonstrate strpbrk function.
strpbrk function locate the first occurrence pointed by the of string s1 from the string pointed to by s2. In this program, We Turns miscellaneous field separators into just a space separating tokens for easy parsing by SSCANF. Eventually, the character separators and replacement character will be passed in as strings. Read more about C Programming Language .

/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/
#include <stdio.h>
#include <string.h>
#include <strings.h>

#define LINE_BUF 100

void find_comment(char *);

main()
{
char line[LINE_BUF];
char *sep;
int var1, var2;

while (fgets(line, LINE_BUF, stdin)) {

/*
* Check this out: Since SEP is a pointer to type char, when line is
* assigned to sep, really the first address is assigned to sep. LINE
* is the address of the start of the string. In contrast, LINE[0]
* is the first character of the string.
*/

sep = line;

while (sep != 0) {
sep = strpbrk(line, ";.&:,");
if (sep != 0)
*sep = ' ';
}
fputs(line, stdout);
}
return 0;
}
Read more c programs 
C Basic
C Strings

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

To browse more C Programs visit this link
(c) www.c-program-example.com

C Program to demonstrate sscanf statement.

C Program to demonstrate the ‘sscanf’ statement.
sscanf statement reads formatted data from the string, Different syntax of sscanf are:
A = sscanf(str, format)
A = sscanf(str, format, sizeA)
[A, count] = sscanf(…)
[A, count, errmsg] = sscanf(…)
[A, count, errmsg, nextindex] = sscanf(…).Read more about C Programming Language .

/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/

#include <stdio.h>

main()
{
char Host[64];
char User[64];
char *Buff = "Jobname=job1 Hostname=arnamul User=leslim Time=11:15";
/* <----------> <-----> <---------> <-------->
* | | | |
* | ------------ | |
* | | ------------------ V
* | | | NULL
* V V V */
sscanf (Buff, "%*s Hostname=%s %s", Host, User);

printf("Host is %sn", Host);
printf("User is %sn", User);
exit(0);
}


Read more c programs 
C Basic
C Strings
K and R C Programs Exercise

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

To browse more C Programs visit this link
(c) www.c-program-example.com

C Program to demonstrate sprintf statement.

C Program to demonstrate the ‘sprintf‘ statement. This example is a bit lame as the same effect can be seen with a ‘printf’. But, it does show a string being built and passed into a function. Read more about C Programming Language .

/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/

#include <stdio.h>

main()
{
int i=1; /* Define an integer variable. */
char message[80]; /* Text string */

/* format text and put into 'message' this a great
* improvement over using 'strcpy' and 'strcat' to
* build a text string.
*/
sprintf (message, "i is %i", i);
/* I may be stating the obvious but a '' is
* put on the end of the string. */

puts(message); /* Display message */

}

Read more c programs 
C Basic
C Strings
K and R C Programs Exercise

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

To browse more C Programs visit this link
(c) www.c-program-example.com

C Program to print ASCII values of all characters.

C Program to print ASCII values of all characters.
ASCII value is the American Standard Code for Information Interchange.
ASCII value is the numerical value, or order, of an character. There are 128 standard ASCII characters, numbered from 0 to 127. Extended ASCII adds another 128 values and goes to 255. The numbers are typically represented in decimal or in hexadecimal. Read more about C Programming Language .

/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/

#include<stdio.h>
#include<conio.h>
int main(){

int i;
clrscr();
for(i=0;i<=255;i++)
printf("ASCII value of
character %c: %dn",i,i);
getch();
return 0;

}
Read more Similar C Programs
Learn C Programming

Number System

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

To browse more C Programs visit this link
(c) www.c-program-example.com

C Program to find the strong number.

Write a C Program to find the given number is strong or not?
A number is called strong number if sum of the factorial of its digit is equal to number itself.
Example: 145 since 1! + 4! + 5! = 1 + 24 + 120 = 145.
Read more about C Programming Language .

/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/
#include<stdio.h>
#include<conio.h>

int main()
{
int num,i,f,r,sum=0,num1;
clrscr();
printf("Enter a number: ");
scanf("%d",&num);

num1=num;
while(num){
i=1,f=1;
r=num%10;

while(i<=r){
f=f*i;
i++;
}
sum=sum+f;
num=num/10;

}
if(sum==num1)
printf("%d is a strong number",num1);
else
printf("%d is not a strong number",num1);
getch();
return 0;

}
Read more Similar C Programs
Learn C Programming

Number System

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

To browse more C Programs visit this link
(c) www.c-program-example.com

C Program to add one to digits of a number

Write C Program to add one to digits of a number.
C Program that adds the 1 to each single digit of a number, i.e for Example 12345’s output is 23456.
If the digit is 9 it adds 1 and follows the carry system, 9 becomes 0 and 9’s left digit adds one more 1. I.e., 3491’s output is 4602. Read more about C Programming Language .

/***********************************************************
* You can use all the programs on  www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
* 
*                      Happy Coding
***********************************************************/

#include<stdio.h>
#include<conio.h>
int main()
{
 int num, sum = 0;
 int rem, check = 0;
 clrscr( );
 printf("Enter the required number:");
 scanf("%d",&num);
 printf("nGiven Number: %d",num);
 while(num>0) 
 {
  rem = num % 10;
  if(rem != 9)
  {
   if(check == 0) 
    sum = (10 * sum) + (rem + 1);
   else{
    sum = (10*sum) + (rem + 2);
    check = 0;
   }
  } 
  else{
   sum = (10 * sum) + 0;
   check = 1;
  }
  num = num/10;
 } 

 num = sum; sum=0;
 while(num > 0)
 {
  rem = num % 10;
  sum = (10*sum) + rem;
  num = num / 10;
 }
 printf("nAfter Adding one: %d",sum);
 getch( );
 return 0;
}
Read more Similar C Programs
Learn C Programming
Number System

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now, our page!

Share this program with your Facebook friends now! by liking it

Like to get updates right inside your feed reader? Grab our feed!
(c) www.c-program-example.com

C Program to print factors of the number.

Write a C Program to print factors of a number. Factors of a whole number are the whole numbers which are exactly divides the number. i.e reminder is equal to zero.
Example: Factors of 8 are: 1, 2, 4, and 8.
Read more about C Programming Language .

/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/

#include<stdio.h>
#include<conio.h>
{
void main( )
{
int num,x;
clrscr( );
printf("Enter the required number:");
scanf("%d",&num);
printf("nThe factors are:");
for(x=1; x<=num; x++)
{
if(num%x==0)
printf("n%d",x);
}
getch( );
}
Read more Similar C Programs
C Basic
C Search Algorithms
K and R C Programs Exercise

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

To browse more C Programs visit this link
(c) www.c-program-example.com

C Program to get the system information.

C Program to get the system information. We can use the ‘uname’ function to get the system information, which is defined in the “sys/utsname.h” library.Structure is used to hold information returned by the uname function.
“uname” function members and their use:
sysname returns the name of the operating system in use.
release returns the current release level of the operating system implementation.
version returns the current version level within the release of the operating system.
machine is the description of the type of hardware that is in use.
Read more about C Programming Language.

/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/


#include<sys/utsname.h> /* Header for 'uname' */

main()
{
struct utsname uname_pointer;

uname(&uname_pointer);

printf("System name - %s n", uname_pointer.sysname);
printf("Nodename - %s n", uname_pointer.nodename);
printf("Release - %s n", uname_pointer.release);
printf("Version - %s n", uname_pointer.version);
printf("Machine - %s n", uname_pointer.machine);
printf("Domain name - %s n", uname_pointer.domainname);
}


Read more Similar C Programs
Learn C Programming

Number System

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

To browse more C Programs visit this link
(c) www.c-program-example.com

C program to illustrate the concept of unions

C program to demonstrate unions. unions are like C structures, but every member occupies the same memory region. Read more about C Programming Language .

/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/

#include <stdio.h>
#include <conio.h>

void main()
{
union number
{
int n1;
float n2;
};

union number x;

clrscr() ;

printf("Enter the value of n1: ");
scanf("%d", &x.n1);
printf("Value of n1 =%d", x.n1);

printf("nEnter the value of n2: ");
scanf("%d", &x.n2);
printf("Value of n2 = %dn",x.n2);

}
Read more Similar C Programs
Union.

Structures.

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com