Saturday, November 13, 2010

How to display the message box through Command Prompt



How to display the message box through Command Prompt

Procedure:

Step 1: Go to “Start” Menu and Click Run option.
Step 2: Enter “cmd” in drop down box.

Step 3: In CMD window, Type as “msg Console [User Content]”.

Ex: msg console Enjoy life with new technology!!!

OUTPUT:
 

Monday, November 1, 2010

How to find the variable size without using Sizeof function

/*
 * sizeofVariable.c
 * Author : karthikeyan.D
 * Date: 1-Nov-2010
 *
 */
/* please refer this following statements.
#ifndef __SIZE_T
#define __SIZE_T
typedef unsigned int size_t;
#endif
.... meaning that on this particular implementation `size_t' is
an `unsigned int'.

*/


# include <stdio.h>
# include <stdlib.h>
//user definition
# define size_var( var ) ((size_t)(&(var)+1)-(size_t)(&(var)))

int main()
{
    int nVal;
    char cChar;
    printf("size of :%d\n",size_var(nVal));
    printf("size of :%d",size_var(cChar));
    return 0;
}

Friday, October 29, 2010

structure inside the another structure

/*
 * Structure inside the another structure.c
 *
 *  Created on: Oct 19, 2010
 *      Author: Karthikeyan.D
 */

# include <malloc.h>
struct employee
{
    int nage;
    int nsex;

};

struct NetSim
{
    int nTest;
    struct employee *pstruEmp;
};

struct NetSim *pstruNetsimDepartment =NULL;


# include <stdio.h>
int main()
{
  //To create  a memory for first structure
    pstruNetsimDepartment = (struct NetSim * )malloc (sizeof(struct NetSim *));

  //To create  a memory for second structure
    pstruNetsimDepartment->pstruEmp = (struct employee * )malloc (sizeof(struct employee *));

    // To assign the employee age as ten

    pstruNetsimDepartment->pstruEmp->nage =10;
// echo this meesge
    printf("%d",pstruNetsimDepartment->pstruEmp->nage);
    return 0;
}

Wednesday, October 20, 2010

netsh command usage

Sample:

INPUT:

netsh interface ip show address "Local Area Connection 2"

OUTPUT:

Tuesday, October 19, 2010

Sample make File

myprogram:
g++ stack.c -o stack.exe
g++ revfile.c -o revfile.exe
clean:
rm -rf *.o *.exe

Friday, October 15, 2010

Memory Reference Problem

/*
* StruMem.c
*
* Created on: Oct 15, 2010
* Author: KArthikeyan.D
*
*/
# include <stdio.h>
# include <malloc.h>
# include <string.h>
typedef struct struture1
{
int a;
int b;

}stru;

int main()
{
stru *Memory = (stru*)malloc(sizeof(stru));
//Memory = NULL;

Memory->a=12;
Memory->b = 21;

free(Memory);
printf("%d ",Memory->b);
return 0;
}

Note: View last two lines. Memory freed . After that we are trying to get the value.

OutPut: Garbage value

Sunday, October 10, 2010

How to print the single linked list in reverse order without using array or memory?

/*
* list1.c
* Display the single linked list in reverse order
* Created on: Oct 11, 2010
* Author: Karthikeyan.D
*/

#include<stdio.h>
#include<conio.h>
#include<malloc.h>
typedef struct struNode
{
int nVal;
struct struNode *pstruNext;
}pstruStart;

int fnReversePrint(pstruStart* nTempLoation);

int fnReversePrint(pstruStart* nTempLoation)
{

if(nTempLoation->pstruNext != NULL)
{
fnReversePrint(nTempLoation->pstruNext);
printf("-->%d",nTempLoation->nVal);
}
else
{
printf("NULL-->%d",nTempLoation->nVal);
}

return 0;

}
int main()
{
struct struNode *pstruStart=NULL;
struct struNode *pstruNewnode,*pstruCurrent;

int nN;
int nI;

printf("enter the number of nodes\n");
scanf("%d",&nN);
for(nI=0;nI<nN;nI++)
{
pstruNewnode=(struct struNode*)malloc(sizeof(struct struNode));
printf("enter the data\n");
scanf("%d",&pstruNewnode->nVal);
pstruNewnode->pstruNext=NULL;
if(pstruStart==NULL)
{
pstruStart=pstruNewnode;
pstruCurrent=pstruNewnode;
}
else
{
pstruCurrent->pstruNext=pstruNewnode;
pstruCurrent=pstruNewnode;
}
}
printf("the linked list is\n");
pstruNewnode=pstruStart;
while(pstruNewnode!=NULL)
{
printf("%d----->",pstruNewnode->nVal);
pstruNewnode=pstruNewnode->pstruNext;
}
printf("NULL\n");


fnReversePrint(pstruStart);

return 0;

}

INPUT:

enter the number of nodes: 5
enter the data: 10
enter the data: 20
enter the data: 30
enter the data: 40
enter the data: 50

OUTPUT:
the linked list is
10----->20----->30----->40----->50----->NULL
NULL-->50-->40-->30-->20-->10

Sunday, October 3, 2010

Counting bits

/*
* To count the number bits used for the value representation.
*/

# include <stdio.h>
# include < stdlibb.h>

int bitcount(unsigned char x)
{ int count;
for (count=0; x != 0; x>>=1)
if ( x & 01) count++;
return count;
}
int main()
{
int BitCount;


BitCount = bitcount(10);

printf("Number of BitCount = %d\n ",BitCount);


return 0;
}

Timer Problem

/* timer.c */
/* Computes the time in seconds to do a computation */
#include <stdio.h>
#include <sys/types.h>
#include <time.h>
main()
{ int i;
time_t t1,t2;
(void) time(&t1);
for (i=1;i<=1000;++i)
printf(``%d %d %dn'',i, i*i, i*i*i);
(void) time(&t2);
printf(``n Time to do 1000 squares and
cubes= %d secondsn'', (int) t2-t1);
}

Tuesday, September 28, 2010

Pointer Size in gcc Compiler

/*
* PointerSize.c
*
* Created on: Sep 29, 2010
* Author: Karthikeyan.D
*/
/* Size of any type of pointer is independent of the data
* type which is it is pointing i.e. size of pointer is always fixed.
* Size of any type (near) of pointer in c is four byte. (gcc Compiler)
*/
#include <stdio.h>
int main()
{
int *p1;
long double *p2;
printf("%d %d",sizeof(p1),sizeof(p2));

return 0;
}



OUTPUT:

4 4

Directory finding



/*
* Finding the files in the particular files.
*
*/

#include <stdio.h>
#include <sys/types.h>
#include <dirent.h>
# include <string.h>


int isFileExist(char* dirName, char* fileName)
{
DIR *dp;
struct dirent *ep;
dp = opendir ("./");

if (dp != NULL)
{
while(ep = readdir(dp))
{
puts (ep->d_name);
if(strcmp(fileName, ep->d_name) ==0)
return 0;
}
(void) closedir (dp);
}
else
perror ("Couldn't open the directory");
return -1;

}

int main (void)
{

printf("is Exist %d",isFileExist("./","Printf.c"));
//perror("flfllfglllglf");
/* DIR *dp;
struct dirent *ep;
dp = opendir ("./");

if (dp != NULL)
{
while(ep = readdir(dp))
puts (ep->d_name);

(void) closedir (dp);
}
else
perror ("Couldn't open the directory"); */

return 0;
}

Sunday, September 26, 2010

Printf Concept


/*
* Printf.c
*printf return the number of characters which is to be displayed in the console window.
* Created on: Sep 26, 2010
* Author: Karthikeyan.D
*/


# include <stdio.h>
int main()
{
int nCount=0;
nCount = printf("Hello India\n");
printf("%d",nCount);
return 0;
}

OUTPUT:

Hello World
12


Note: \n consider as a escape sequence and also number of character count for this is only one. not two.



What is Data Abstraction?

Data Abstraction is a process of representing the essential features without including background or implementation level details.

Tuesday, May 25, 2010

Program to convert Days to Months (30 days) and days

/*
* Program to convert Days to Months (30 days) and days.c
*
* Created on: May 25, 2010
* Author: Karthikeyan
*/

# include <stdio.h>
# include <stdlib.h>

int main()
{
int months,days;
printf("Enter days\n");
scanf("%d",&days);
months = days / 30;
days = days % 30;
printf("Months = %d \n Days = %d",months,days);
return 0;
}


OUTPUT:


Enter days 365
Months = 12
Days = 5

Friday, May 21, 2010

Alphabets


/*
* Printing .c
* Alphabet Set inDecimal and Character Form
* Created on: May 21, 2010
* Author: Karthikeyan.D
*/

#include<stdio.h>
int main()
{
char c;
printf("\n\n");
for(c=65;c<=122;c=c++)
{
if(c>90&& c<97)
continue;
printf("%6d -- %c",c,c);

}
printf("\n");
return 0;
}

OUTPUT:


65 -- A 66 -- B 67 -- C 68 -- D 69 -- E 70 -- F 71 -- G
72 -- H 73 -- I 74 -- J 75 -- K 76 -- L 77 -- M 78 -- N
79 -- O 80 -- P 81 -- Q 82 -- R 83 -- S 84 -- T 85 -- U
86 -- V 87 -- W 88 -- X 89 -- Y 90 -- Z 97 -- a 98 -- b
99 -- c 100 -- d 101 -- e 102 -- f 103 -- g 104 -- h 105 -- i
106 -- j 107 -- k 108 -- l 109 -- m 110 -- n 111 -- o 112 -- p
113 -- q 114 -- r 115 -- s 116 -- t 117 -- u 118 -- v 119 -- w
120 -- x 121 -- y 122 -- z

Printing Sequnce-3


/*
* Printing_Sequence.c
*
* Created on: May 21, 2010
* Author: karthikeyan.D
*
*/
#include<stdio.h>
#include<string.h>
int main()
{
int c, d,lent;
static char string[]="WelcomeTamilnadu";
lent=strlen(string);
printf("\n\n");
printf("------------------------------------\n");
for(c=0;c<=lent-1;c++)
{
d=c+1;
printf("|%*.*s|",lent,d,string);
printf("|%-*.*s|\n",lent,d,string);

}
printf("------------------------------------\n");
for(c=lent-1;c>=0;c--)
{
d=c+1;
printf("|%*.*s|",lent,d,string);
printf("|%-*.*s|\n",lent,d,string);
}
printf("------------------------------------\n");
return 0;
}

OUTPUT:

------------------------------------
| W||W |
| We||We |
| Wel||Wel |
| Welc||Welc |
| Welco||Welco |
| Welcom||Welcom |
| Welcome||Welcome |
| WelcomeT||WelcomeT |
| WelcomeTa||WelcomeTa |
| WelcomeTam||WelcomeTam |
| WelcomeTami||WelcomeTami |
| WelcomeTamil||WelcomeTamil |
| WelcomeTamiln||WelcomeTamiln |
| WelcomeTamilna||WelcomeTamilna |
| WelcomeTamilnad||WelcomeTamilnad |
|WelcomeTamilnadu||WelcomeTamilnadu|
------------------------------------
|WelcomeTamilnadu||WelcomeTamilnadu|
| WelcomeTamilnad||WelcomeTamilnad |
| WelcomeTamilna||WelcomeTamilna |
| WelcomeTamiln||WelcomeTamiln |
| WelcomeTamil||WelcomeTamil |
| WelcomeTami||WelcomeTami |
| WelcomeTam||WelcomeTam |
| WelcomeTa||WelcomeTa |
| WelcomeT||WelcomeT |
| Welcome||Welcome |
| Welcom||Welcom |
| Welco||Welco |
| Welc||Welc |
| Wel||Wel |
| We||We |
| W||W |
------------------------------------

Printing Sequnce -2


/*
* Printing_Sequence.c
*
* Created on: May 21, 2010
* Author: karthikeyan.D
*
*/
#include<stdio.h>
#include<string.h>
int main()
{
int c, d,lent;
static char string[]="WelcomeTamilnadu";
lent=strlen(string);
printf("\n\n");
printf("------------------------------------\n");
for(c=0;c<=lent-1;c++)
{
d=c+1;
printf("|%-16.*s|",d,string);
printf("|%16.*s|\n",d,string);
}
printf("------------------------------------\n");
for(c=lent-1;c>=0;c--)
{
d=c+1;
printf("|%-16.*s|",d,string);
printf("|%16.*s|\n",d,string);
}
printf("------------------------------------\n");
return 0;
}


OUTPUT:

------------------------------------
|W || W|
|We || We|
|Wel || Wel|
|Welc || Welc|
|Welco || Welco|
|Welcom || Welcom|
|Welcome || Welcome|
|WelcomeT || WelcomeT|
|WelcomeTa || WelcomeTa|
|WelcomeTam || WelcomeTam|
|WelcomeTami || WelcomeTami|
|WelcomeTamil || WelcomeTamil|
|WelcomeTamiln || WelcomeTamiln|
|WelcomeTamilna || WelcomeTamilna|
|WelcomeTamilnad || WelcomeTamilnad|
|WelcomeTamilnadu||WelcomeTamilnadu|
------------------------------------
|WelcomeTamilnadu||WelcomeTamilnadu|
|WelcomeTamilnad || WelcomeTamilnad|
|WelcomeTamilna || WelcomeTamilna|
|WelcomeTamiln || WelcomeTamiln|
|WelcomeTamil || WelcomeTamil|
|WelcomeTami || WelcomeTami|
|WelcomeTam || WelcomeTam|
|WelcomeTa || WelcomeTa|
|WelcomeT || WelcomeT|
|Welcome || Welcome|
|Welcom || Welcom|
|Welco || Welco|
|Welc || Welc|
|Wel || Wel|
|We || We|
|W || W|
------------------------------------

Printing Sequence


/*
* Printing_Sequence.c
*
* Created on: May 21, 2010
* Author: karthikeyan.D
*
*/
#include<stdio.h>
#include<string.h>
int main()
{
int c, d,len;
static char string[]="WelcomeTamilnadu";
len=strlen(string);
printf("\n\n");
printf("-------------------\n");
for(c=0;c<=len-1;c++)
{
d=c+1;
printf("|%-16.*s|\n",d,string);
}
printf("-------------------\n");
for(c=len;c>=0;c--)
{
d=c+1;
printf("|%-16.*s|\n",d,string);
}
printf("-------------------\n");
return 0;
}

OUTPUT:

-------------------
|W |
|We |
|Wel |
|Welc |
|Welco |
|Welcom |
|Welcome |
|WelcomeT |
|WelcomeTa |
|WelcomeTam |
|WelcomeTami |
|WelcomeTamil |
|WelcomeTamiln |
|WelcomeTamilna |
|WelcomeTamilnad |
|WelcomeTamilnadu|
-------------------
|WelcomeTamilnadu|
|WelcomeTamilnadu|
|WelcomeTamilnad |
|WelcomeTamilna |
|WelcomeTamiln |
|WelcomeTamil |
|WelcomeTami |
|WelcomeTam |
|WelcomeTa |
|WelcomeT |
|Welcome |
|Welcom |
|Welco |
|Welc |
|Wel |
|We |
|W |
-------------------

Sunday, April 4, 2010

how to change the cmd color through C program

# include <stdio.h>
# include < windows.h>
int main()
{
system(color 5e);
printf("hi this is karthiken07@gmail.com");
getch();
return 0;
}

Output:
please open through CMD window.


Wednesday, January 20, 2010

How to Open cmd using c program

#include<stdio.h>
#include<windows.h>

#include<shellapi.h>

int main()
{
int iReturn = (int) ShellExecute(NULL, "open", "ipconfig", "E:\\WORK\\ipconfigCommand", NULL, SW_SHOWNORMAL);
//> ipconfigoutput.txt
if (iReturn <= 32)
{
MessageBox (NULL,"Cannot open file. File may have been moved or deleted.", "Error!", 0) ;

}

return 0;
}

How to run exe using c program

/*
* This program is used to find the CMD Commands using C Programing
* Here we used system function.
*syntax for system Function is
* int system("const char command");
* For this we need to include Windows.h file.
*/
#include<stdio.h>
#include<windows.h>


int main()
{

system("ipconfig>ipconfig.txt");
system("ping 192.168.0.153>Ping.txt");
//system("notepad.exe");
return 0;
}

Thursday, January 7, 2010

Create a text Box in html

TEXTAREA NAME="Karthi likes feedback from U" COLS=20 ROWS=10 /TEXTAREA

Useful CMD Commands

To Access… Run Command
 To Access… Run Command
Accessibility Controls access.cpl
Accessibility Wizard accwiz
Add Hardware Wizard hdwwiz.cpl
Add/Remove Programs appwiz.cpl
Administrative Tools control admintools
Adobe Acrobat (if installed) acrobat
Adobe Designer (if installed) formdesigner
Adobe Distiller (if installed) acrodist
Adobe ImageReady (if installed) imageready
Adobe Photoshop (if installed) photoshop
Automatic Updates wuaucpl.cpl
Bluetooth Transfer Wizard fsquirt
Calculator calc
Certificate Manager certmgr.msc
Character Map charmap
Check Disk Utility chkdsk
Clipboard Viewer clipbrd
Command Prompt cmd
Component Services dcomcnfg
Computer Management compmgmt.msc
Control Panel control
Date and Time Properties timedate.cpl
DDE Shares ddeshare
Device Manager devmgmt.msc
Direct X Control Panel (if installed)* directx.cpl
Direct X Troubleshooter dxdiag
Disk Cleanup Utility cleanmgr
Disk Defragment dfrg.msc
Disk Management diskmgmt.msc
Disk Partition Manager diskpart
Display Properties control desktop
Display Properties desk.cpl
Display Properties (w/Appearance Tab Preselected) control color
Dr. Watson System Troubleshooting Utility drwtsn32
Driver Verifier Utility verifier
Event Viewer eventvwr.msc
Files and Settings Transfer Tool migwiz
File Signature Verification Tool sigverif
Findfast findfast.cpl
Firefox (if installed) firefox
Folders Properties folders
Fonts control fonts
Fonts Folder fonts
Free Cell Card Game freecell
Game Controllers joy.cpl
Group Policy Editor (XP Prof) gpedit.msc
Hearts Card Game mshearts
Help and Support helpctr
HyperTerminal hypertrm
Iexpress Wizard iexpress
Indexing Service ciadv.msc
Internet Connection Wizard icwconn1
Internet Explorer iexplore
Internet Properties inetcpl.cpl
Internet Setup Wizard inetwiz
IP Configuration (Display Connection Configuration) ipconfig /all
IP Configuration (Display DNS Cache Contents) ipconfig /displaydns
IP Configuration (Delete DNS Cache Contents) ipconfig /flushdns
IP Configuration (Release All Connections) ipconfig /release
IP Configuration (Renew All Connections) ipconfig /renew
IP Configuration (Refreshes DHCP & Re-Registers DNS) ipconfig /registerdns
IP Configuration (Display DHCP Class ID) ipconfig /showclassid
IP Configuration (Modifies DHCP Class ID) ipconfig /setclassid
Java Control Panel (if installed) jpicpl32.cpl
Java Control Panel (if installed) javaws
Keyboard Properties control keyboard
Local Security Settings secpol.msc
Local Users and Groups lusrmgr.msc
Logs You Out Of Windows logoff
Malicious Software Removal Tool mrt
Microsoft Access (if installed) msaccess
Microsoft Chat winchat
Microsoft Excel (if installed) excel
Microsoft Frontpage (if installed) frontpg
Microsoft Movie Maker moviemk
Microsoft Paint mspaint
Microsoft Powerpoint (if installed) powerpnt
Microsoft Word (if installed) winword
Microsoft Syncronization Tool mobsync
Minesweeper Game winmine
Mouse Properties control mouse
Mouse Properties main.cpl
Nero (if installed) nero
Netmeeting conf
Network Connections control netconnections
Network Connections ncpa.cpl
Network Setup Wizard netsetup.cpl
Notepad notepad
Nview Desktop Manager (if installed) nvtuicpl.cpl
Object Packager packager
ODBC Data Source Administrator odbccp32.cpl
On Screen Keyboard osk
Opens AC3 Filter (if installed) ac3filter.cpl
Outlook Express msimn
Paint pbrush
Password Properties password.cpl
Performance Monitor perfmon.msc
Performance Monitor perfmon
Phone and Modem Options telephon.cpl
Phone Dialer dialer
Pinball Game pinball
Power Configuration powercfg.cpl
Printers and Faxes control printers
Printers Folder printers
Private Character Editor eudcedit
Quicktime (If Installed) QuickTime.cpl
Quicktime Player (if installed) quicktimeplayer
Real Player (if installed) realplay
Regional Settings intl.cpl
Registry Editor regedit
Registry Editor regedit32
Remote Access Phonebook rasphone
Remote Desktop mstsc
Removable Storage ntmsmgr.msc
Removable Storage Operator Requests ntmsoprq.msc
Resultant Set of Policy (XP Prof) rsop.msc
Scanners and Cameras sticpl.cpl
Scheduled Tasks control schedtasks
Security Center wscui.cpl
Services services.msc
Shared Folders fsmgmt.msc
Shuts Down Windows shutdown
Sounds and Audio mmsys.cpl
Spider Solitare Card Game spider
SQL Client Configuration cliconfg
System Configuration Editor sysedit
System Configuration Utility msconfig
System File Checker Utility (Scan Immediately) sfc /scannow
System File Checker Utility (Scan Once At The Next Boot) sfc /scanonce
System File Checker Utility (Scan On Every Boot) sfc /scanboot
System File Checker Utility (Return Scan Setting To Default) sfc /revert
System File Checker Utility (Purge File Cache) sfc /purgecache
System File Checker Utility (Sets Cache Size to size x) sfc /cachesize=x
System Information msinfo32
System Properties sysdm.cpl
Task Manager taskmgr
TCP Tester tcptest
Telnet Client telnet
Tweak UI (if installed) tweakui
User Account Management nusrmgr.cpl
Utility Manager utilman
Windows Address Book wab
Windows Address Book Import Utility wabmig
Windows Backup Utility (if installed) ntbackup
Windows Explorer explorer
Windows Firewall firewall.cpl
Windows Magnifier magnify
Windows Management Infrastructure wmimgmt.msc
Windows Media Player wmplayer
Windows Messenger msmsgs
Windows Picture Import Wizard (need camera connected) wiaacmgr
Windows System Security Tool syskey
Windows Update Launches wupdmgr
Windows Version (to show which version of windows) winver
Windows XP Tour Wizard tourstart
Wordpad write