Basic Union Programs in C

Started by thiruvasagamani, Aug 14, 2008, 11:00 am

previous topic - next topic
Go Down

thiruvasagamani

Program in C for IS Command

Here is the Sample Code Try this


Code: [Select]
#include <stdio.h>

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

{

union dir
{
struct dat
{
int inode;
char file[14];

}a;

char ch[sizeof(struct dat)];

};


union dir m;


int fs,i,j;



if (argc!=2)
{
printf("usage is wrong");
return;
}


fs=open (argv[1], 0);

if (fs==-1)
{
printf("file opening error");
getch();
return;
}


i=read(fs, m.ch, sizeof(struct dat));

while(i>0)
{
printf("%d\t%s\n", m.a.inode, m.a.file);
i=read(fs, m.ch, sizeof(struct dat));
}


close(fs);

getch();



Program in C for IN Command

Here is the Sample Code Try this

Code: [Select]
#include <stdio.h>
#include <conio.h>
#include <io.h>
int main(argc, argv)
int argc;
char * argv[];

{

int i;


if (argc!=3)
{
printf("usage is wrong");
return;
}


i=link(argv[1],argv[2]);

if (i==0)
printf("file are linked");

getch();


Thiruvasakamani Karnan


Go Up
 

Quick Reply

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Note: this post will not display until it's been approved by a moderator.
Name:
Email:
Verification:
Please leave this box empty:

Type the letters shown in the picture
Listen to the letters / Request another image

Type the letters shown in the picture:

shortcuts: alt+s submit/post or alt+p preview