?
Solved

a simple C program

Posted on 2002-04-14
6
Medium Priority
?
168 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

770 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