The Eduladder is a community of students, teachers, and programmers just interested to make you pass any exams. So we help you to solve your academic and programming questions fast.
In eduladder you can Ask,Answer,Listen,Earn and Download Questions and Question papers.
Watch related videos of your favorite subject.
Connect with students from different parts of the world.
Apply or Post Jobs, Courses ,Internships and Volunteering opportunity. For FREE
See Our team
Wondering how we keep quality?
Got unsolved questions? Ask Questions


You are here:Open notes-->VTU-->6-th-semester-Filestructure-labmanual-Program-No-1

6-th semester Filestructure labmanual Program No-1

1. Write a C++ program to read series of names, one per line, from standard input and write these names spelled in reverse order to the standard output using I/O redirection and pipes. Repeat the exercise using an input file specified by the user instead of the standard input and using an output file specified by the user instead of the standard output.


void swap (char &a,char &b)
{
 char temp;
 temp=a;
 a=b;
 b=temp;
}

void reverse(char *name)
{
 int i,j,size;
 size=strlen(name);
 for(i=0,j=size-1;i
    swap(name[i],name[j]);
}

void main(int argc,char *argv[])
{
 char name[30];
 if(argc==1)
 {
  do
  {
   cout<<"enter name\n";
  cin>>name;
  reverse(name);
  cout<
  }
  while(!cin.eof());
  
 }
 else if(argc==3)
 {
  fstream ip,op;
  ip.open(argv[1],ios::in);
  op.open(argv[2],ios::out|ios::app);
  do
  {
   ip>>name;
   reverse(name);
   cout<
   op<
   if(ip.eof())
    break;
  }
 while(1);
 }
 else
  cout<<"error";
}

// ctrl-c to exit !!!
Execution of file -> 1.CPP
1.start ->type  cmd .
2. In commad Prompt type ->  d :-> cd debug ->
3.Create 2 files 1.txt(Enter some names ) and 2.txt (keep it empty )
4. After executing program there will be a file called 1.exe in debug folder.
5. Type in 1.exe 1.txt 2.txt  ( Reversed names will be found in 2.txt )

Editors




You might like this video:Watch more here

Watch more videos from this user Here

Learn how to upload a video and start earning here