Improve company productivity with a Business Account.Sign Up

x
?
Solved

a simple C program

Posted on 2002-04-14
6
Medium Priority
?
174 Views
Last Modified: 2010-04-01
Hi

Cud someone help me with a simple C program to :

1. create a new File with the standard format eg

</html>
...
.. arg1 ... arg2
</html>


and store it in the directory c:/windlws/temp/tmp.html

2. after creating, this C program will execute the tmp.html file.


I know how to set file registry such the file a file file ends with extnesion .xyz,  the registry will know how to call this C program (lookup.exe) to and get the arguments.

as an example, if I click on arg1.xyz, it will call lookup.exe to create a tmp.html (arg1 as the variable)

and then so on ...







0
Comment
Question by:TLTEO
  • 3
  • 3
6 Comments
 
LVL 49

Expert Comment

by:DanRollins
ID: 6939745
#include <stdio.h>
#include <windows.h>

int main( int argc, char* argv[] )
{
     char szFile[]= "c:\\windows\\tmp\\temp.html";

     FILE* f= fopen( szFile, "w+" );

     fprintf( f, "<html><body>\n");
     for (int j=1; j< argc; j++ ) {
          fprintf( f, "command line arg # %d is: <B> %s </B><br>", j, argv[j]);
     }
     fprintf( f, "</body></html>\n");
     fclose( f );

     ShellExecute(0,"open", szFile, 0, 0, SW_SHOW );
     return(0);
}
0
 

Author Comment

by:TLTEO
ID: 6939874
great.

I have compiled b4.  But what is a good free compiler to recommend now??

Also, is there any .dll  that I need in.

I am basically trying to get an exe  to run a java program. Cos java program need a DOS batch file to run and I can get rid of the ugly DOS in win2000.

0
 

Author Comment

by:TLTEO
ID: 6939877
> > >  > >An unemployed man is desperate to support his
> > > family. His wife watches TV all day and his three teenage kids have
> > > dropped out of high school to hang around with the local toughs.
> > > He applies for a janitor's job at a large firm and easily passes an
> > > aptitude test.
> > >  > >
> > >  > >The human resources manager tells him, "You will be
> > > hired at minimum wage of $5.15 an hour. Let me have your
> > > e-mail address so that we can get you in the loop. Our system will
> > > automatically e-mail you all the forms and advise you when to start
and
>
> > > where to report on your first day."
> > >  > >
> > >  > >Taken back, the man protests that he is poor and
> > > has neither a computer nor an e-mail address. To this the manager
> replies,
> > > "You must understand that to a company like ours that means
> > > that you virtually do not exist. Without an e-mail address you can
> hardly
> > > expect to be > >employed by a high-tech firm. Good day."
> > >  > >
> > >  > >Stunned, the man leaves. Not knowing where to turn
> > > and having $10 in his wallet, he walks past a farmers' market and
> > > sees a stand selling 25lb crates of beautiful red tomatoes. He buys a
> > > crate, carries it to a busy corner and displays the tomatoes. In less
> than
> > > 2 hours he sells all the tomatoes and makes 100% profit. Repeating
> > > the process several times more that day, he ends up with almost $100
> > > and arrives home that night with several bags of groceries for his
> > > family.
> > >  > >
> > >  > >During the night he decides to repeat the tomato
> > > business the next day.
> > >  > >By the end of the week he is getting up early every
> > > day and working into the night. He multiplies his profits quickly.
> > > Early in the second week he acquires a cart to transport several boxes
> > > of tomatoes at a time, but before a month is up he sells the cart to
> > > buy a broken-down pickup truck.
> > >  > >
> > >  > >At the end of a year he owns three old trucks. His
> > > two sons have left their neighborhood gangs to help him with the
> > > tomato business, his wife is buying the tomatoes, and his daughter is
> > > taking
> > > night courses at the community college so she can keep books for him.
> > >  > >
> > >  > >By the end of the second year he has a dozen very
> > > nice used trucks and employs fifteen previously unemployed people, all
> > > selling tomatoes.
> > > He continues to work hard. Time passes and at the end
> > > of the fifth year he owns a fleet of nice trucks and a warehouse which
> > > his wife supervises, plus two tomato farms that the boys manage. The
> > > tomato company's payroll has put hundreds of homeless and jobless
> > > people to work. His daughter reports that the business grossed a
> > > million dollars.
> > >  > >
> > >  > >Planning for the future, he decides to buy some
> > > life insurance.  Consulting with an insurance adviser, he picks an
> > > insurance plan to fit his new circumstances.
> > >  > >
> > >  > >Then the adviser asks him for his e-mail address in
> > > order to send the final documents electronically. When the man
> > > replies that he doesn't have time to mess with a computer and has no
> > e-mail
> > > address, the insurance man is stunned, "What, you don't have
> > > e-mail? No computer?
> > >  > >No Internet? Just think where you would be today if
> > > you'd had all of that five years ago!"
> > >  > >
> > >  > >"Ha!" snorts the man. "If I'd had e-mail five years
> > > ago I would be sweeping floors at Microsoft and making $5.15 an
> > > hour."
> > >  > >
> > >  > >Which brings us to the moral:
> > >  > >Since you got this story by e-mail, you're probably
> > > closer to being a janitor than a millionaire.
> > >  > >
> > >  > >Sadly, I received it also.
> > >
>
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
LVL 49

Accepted Solution

by:
DanRollins earned 200 total points
ID: 6940684
Hi TLTEO,

We usually don't post jokes here.  A Topic Area called  'The Lounge' is available for that.

If my post helped you solve your technical problem, please click the [Accept comment as Answer] button next to my comment.  Then click the "Excellent" radio button, then click [Submit].  Thanks!

-- Dan
0
 

Author Comment

by:TLTEO
ID: 6940903
Thanks

Cud you recommend me a good C compiler?
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 6940934
Sure.  Microsoft Visual C++.  There is no other worth using.  Period.

-- Dan
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

601 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question