C Programming Tutorial

 
 
 

Advanced Programming

Array

One dimensional array Two dimensional Array Two dimensional array pointers Array of pointers Print array Print Array - for loop Print array in reverse Print address array - for loop Multidimentional array - function Print address array - pointers Print reverse string of array Print array ascii value-without atoi Character array - upper case Multiplication table - 2D array Passing array to function Max or greatest value in array Merge sorted array Array of structure Array of pointers to string Array within a structure

String Programs

Copy string Substring of string String concatination Vowel in string Swap char in string Palindrome string Rotate string Bubble sort of strings Sorting of words Encode decode string Compress string

File Programs

Read write in 2 files Add,edit,delete,search in file Add,search using structure Append in file Merge file Count word,line,char in file Count record - struct fread() example fwrite() example fopen() example fclose() example fscanf() and fprintf() fseek() example Error handling in file op Find odd,even num Odd even numbers in file Max, min age in class Random numbers file Preprocessor in 2 files Encode decode in file

Bios Programming

biosequip( ) - sys confi biosdisk( ) - partition tbl info Pc type-bios data area File allocation table Telephone directory

TSR Programming

Interchange letters Interchange letters on screen Unload TSR on key press-keyboard Unload TSR - timer interrupt Activate, deactivate TSR Print alphabet from printer Repeat key press Keep caps on Make ctrl, alt key pressed

Interrupt Programming

Restart computer Conventional memory of sys Save IVT in file Print string-interrupt 21h Read char-interrupt 21h Read char with echo-interrupt 21h Delete file-interrupt 21h Delete directory-interrupt 21h Get set system date Show system configuration Search, delete file in dir Display multiple file in dir

Mouse Programming

Text mode mouse handling Graphics mode mouse handling Double click of mouse
 
 

Image

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

void main(){
     char string[50],tmp[50];
     int spcnt[50],i,j,c;
     clrscr();
     printf(\"Enter a string : \");
     gets(string);

     //compress logic
     for(i=0,c=0;string[i];i++){
     if(string[i]==\' \'){
        spcnt[c++]=i;
        for(j=i;string[j];j++)
           string[j]=string[j+1];
        string[j]=\'\\0\';
      }
     }
     spcnt[c]=-99;
     textcolor(GREEN);
     printf(\"\\n\");
     cprintf(\"Compressed string is as follow : %s\",string);

     //decompressed logic
     strcpy(tmp,\"\");
     for(i=0,c=0;string[i];i++){
     if(spcnt[c]==i){
        tmp[i+c]=\' \';
        c++;
        tmp[i+c]=string[i];
     }
     else{
        tmp[i+c]=string[i];
     }
     }
     tmp[i+c]=\'\\0\';
     strcpy(string,tmp);
     textcolor(RED);
     printf(\"\\n\");
     cprintf(\"De-Compressed string is as follow : %s\",string);
    getch();
}

    Related Post:
  1. Program to multiply two polynomials maintained as linked lists

  2. Program that displays use of extern variable

  3. Program to compare one string s2 to another string s1. Print the difference of first unmatched characters using strcmp function from string.h

  4. Program to display number triangle

  5. Implement a multi-access threaded queue with multiple threads inserting and multiple threads extracting from the queue

  6. Program to copy the contents of one array to another Using Shared Memory

  7. Program that illustrates the use of malloc and calloc functions

  8. Program to print input text in upper case

  9. PROGRAM TO CONVERT BINARY FLOTING POINT TO HEXADECIMAL FLOTING POINT

  10. Stack using linked list

  11. Program to concatenate of two strings without using strcat function

  12. PROGRAM FOR FORWARD SCHEDULING FOR EQUAL DISTRIBUTION

  13. Program to compute x to the power n using while loop

  14. Program of solving the dependency in the linear recurrence relation x[i] = x[i-1] + y[i] using block scheduling

  15. Program to print triangle of numbers in reverse pattern

  16. Program that will accept a line of text from the text file; count the number of words, lines, and characters in the file

  17. Using the POSIX threads library, write a 2-thread program for Linux.Once the thread spawning is done, the first thread (T1) should wait for user input

  18. Program of matrix transpose and matrix multiplication

  19. Program for Number Conversion from Decimal to Binary, Decimal to Octal, Decimal to Hexa, Binary to Octal, Binary to Hexa, Octal to Hexa

  20. Program to find the maximum and minimum element in an array using threads

 
 
Didn't find what you were looking for? Find more on Program to compress given string