Implementation of mkdir command

/*Implementation of mkdir command */

#include<stdio.h>

#include<stdlib.h>

#include<sys/stat.h>

void usage(const char *myname)

{

printf(“\nUsage: %s <pathname> [<mode>]\n\n”, myname);

exit(1);

}

void main(int argc, char *argv[])

{

int mode;

if(argc<2)

usage(argv[0]);

if(argc==2)

mode = 0777;

elseif(sscanf(argv[2], “%o”, &mode==0)

{

printf(“%s : Invalid Mode\n”, argv[0]);

exit(1);

}

if(mkdir(argv[1], mode)== -1)

perror(argv[0]);

else

printf(“%s directory is created successfully”, argv[1]);

}

DDA Line Drawing Algorithm using C

DDA Line Drawing Algorithm

#include<stdio.h>

#include<conio.h>

#include<graphics.h>

#include<ctype.h>

#include<math.h>

#include<stdlib.h>

void draw(int x1,int y1,int x2,int y2);

void main()

{

int x1,y1,x2,y2;

int gdriver=DETECT,gmode,gerror;

initgraph(&gdriver,&gmode,”c:\\tc\\bgi:”);

printf(“\n Enter the x and y value for starting point:\n”);

scanf(“%d%d”,&x1,&y1);

printf(“\n Enter the x and y value for ending point:\n”);

scanf(“%d%d”,&x2,&y2);

Read More…

Creation of a Simple Menu

Program to display a simple menu

#include <afxwin.h>

#include “resource.h”

class myframe:public CFrameWnd

{

private:

CMenu menu;

public:

myframe()

{

Create(0,”Creating Menu Using LoadMenu and SetMenu”);

}

int OnCreate(LPCREATESTRUCT I)

{

CFrameWnd ::OnCreate(I);

menu.LoadMenu(IDR_MENU1);

SetMenu(&menu);

return 0;

}

Read More…