Solved

a simple C program

Posted on 2002-04-14
6
162 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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 49

Accepted Solution

by:
DanRollins earned 50 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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.

707 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now