Reading a file & output a file 
Author Message
 Reading a file & output a file

Hello:

I want to write a little Program for output the collection File.

It will have 2 Files (Catalogue.txt & Invoice.txt)

Catalogue File Format in TXT
=================
458455 Jif-Cloth 7.90
013953 Limpio-Sponge 6.50
705491 No-Frills-Sponge 4.90
457259 Scotchbrite-Spiral-Ball 7.90

Order File Format in TXT
==================
013953 4
705491 1

458455 1

705491 2
===================

After Process "Calculate.exe Catalogue.txt  Order.txt"
it will Generate Invoice.txt File

Program need to output file in TXT Format
==========================
458455 Jif-Cloth $7.90
705491 No-Frills-Sponge $14.70
013953 Limpio-Sponge $26.00

Gross total is $48.60
==========================

I have write some of the code but not finish.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define IDSIZE 6
#define NAMESIZE 256

struct item {
  char id[IDSIZE + 1];
  char name[NAMESIZE];
  float price;
  struct item* next;

Quote:
};

int main(int argc, char** argv) {
  int count;
  char* catfilename;
  char* orderfilename;
  char invoicefilename[256] = "invoice.txt";

  FILE* catfile;
  FILE* orderfile;
  FILE* outfile;

  if (argc < 3) {
    printf("Usage: %s [catalog file] [order file]\n", argv[0]);
    return 1;
  }

  catfilename = argv[1];
  orderfilename = argv[2];
  strcat(invoicefilename, orderfilename);

  /*
    at this point, the filenames are stored in the variables catfilename
for
    catalogue file, orderfile for the order file, and outfile for the
invoice file,
    is I am right?
  */

  return 0;

Quote:
}

Thanks!

--

Best Regards,
Alan Tang



Thu, 22 Sep 2005 09:31:31 GMT  
 Reading a file & output a file

Quote:
> Hello:

> I want to write a little Program for output the collection File.

> It will have 2 Files (Catalogue.txt & Invoice.txt)
[snip]
> After Process "Calculate.exe Catalogue.txt  Order.txt"
> it will Generate Invoice.txt File
[snip]
> int main(int argc, char** argv) {
>   int count;
>   char* catfilename;
>   char* orderfilename;
>   char invoicefilename[256] = "invoice.txt";

>   FILE* catfile;
>   FILE* orderfile;
>   FILE* outfile;

>   if (argc < 3) {
>     printf("Usage: %s [catalog file] [order file]\n", argv[0]);
>     return 1;
>   }

>   catfilename = argv[1];
>   orderfilename = argv[2];
>   strcat(invoicefilename, orderfilename);

If argv[2] = "Order.txt", then catenating it to "invoice.txt" yields
"invoice.txtOrder.txt".  Is that really what you want?

I couldn't find another question to answer...

--



Thu, 22 Sep 2005 11:37:57 GMT  
 Reading a file & output a file
Thanks, Please ignore the line! Do you have any idea that about the
unfinished code?
Quote:


> > Hello:

> > I want to write a little Program for output the collection File.

> > It will have 2 Files (Catalogue.txt & Invoice.txt)
> [snip]
> > After Process "Calculate.exe Catalogue.txt  Order.txt"
> > it will Generate Invoice.txt File
> [snip]
> > int main(int argc, char** argv) {
> >   int count;
> >   char* catfilename;
> >   char* orderfilename;
> >   char invoicefilename[256] = "invoice.txt";

> >   FILE* catfile;
> >   FILE* orderfile;
> >   FILE* outfile;

> >   if (argc < 3) {
> >     printf("Usage: %s [catalog file] [order file]\n", argv[0]);
> >     return 1;
> >   }

> >   catfilename = argv[1];
> >   orderfilename = argv[2];
> >   strcat(invoicefilename, orderfilename);

> If argv[2] = "Order.txt", then catenating it to "invoice.txt" yields
> "invoice.txtOrder.txt".  Is that really what you want?

> I couldn't find another question to answer...

> --




Thu, 22 Sep 2005 11:46:48 GMT  
 Reading a file & output a file

Quote:
> Thanks, Please ignore the line! Do you have any idea that about the
> unfinished code?

Please post responses after quoted material and remove unnecessary
lines (as is the case here).

I know how to do your homework.  But you won't learn anything if I
do it for you.  Are you having some problem with a part of the
C language in formulating your solution?  Or perhaps, you haven't
thought through how to solve the problem?

--



Thu, 22 Sep 2005 15:13:07 GMT  
 Reading a file & output a file
Yes, I am doing my homework. Due to my company request. I am not at my
country side. It was telling by my classmate. Unlucky, the deadline is
tomorrow 07/04/2003 13:00 GMT+8 by electronic submission. So, I need to
do it ASAP. I just remain two question to finish my homework. I just get
the only information by my classmate. I am not family with stack and link
list. So, I got problem on the remain question. Do you have any
information about the link list?

Thanks!

Quote:


> > Thanks, Please ignore the line! Do you have any idea that about the
> > unfinished code?

> Please post responses after quoted material and remove unnecessary
> lines (as is the case here).

> I know how to do your homework.  But you won't learn anything if I
> do it for you.  Are you having some problem with a part of the
> C language in formulating your solution?  Or perhaps, you haven't
> thought through how to solve the problem?

> --




Thu, 22 Sep 2005 15:48:58 GMT  
 Reading a file & output a file
I just got the example of using link list with the following format:

typedef struct stack_node stack_list;
typedef stack_list *link;

I don't know the different between typedef stack_list *link; and typedef
stack_list* link;

Quote:

> Yes, I am doing my homework. Due to my company request. I am not at my
> country side. It was telling by my classmate. Unlucky, the deadline is
> tomorrow 07/04/2003 13:00 GMT+8 by electronic submission. So, I need to
> do it ASAP. I just remain two question to finish my homework. I just get
> the only information by my classmate. I am not family with stack and link
> list. So, I got problem on the remain question. Do you have any
> information about the link list?

> Thanks!



> > > Thanks, Please ignore the line! Do you have any idea that about the
> > > unfinished code?

> > Please post responses after quoted material and remove unnecessary
> > lines (as is the case here).

> > I know how to do your homework.  But you won't learn anything if I
> > do it for you.  Are you having some problem with a part of the
> > C language in formulating your solution?  Or perhaps, you haven't
> > thought through how to solve the problem?

> > --




Thu, 22 Sep 2005 16:09:56 GMT  
 Reading a file & output a file

Quote:

> I just got the example of using link list with the following format:

> typedef struct stack_node stack_list;
> typedef stack_list *link;

> I don't know the different between typedef stack_list *link; and typedef
> stack_list* link;

There isn't one as far as C is concerned. stack_list* link is more logical,
stack_list *link is traditional.


Thu, 22 Sep 2005 17:19:38 GMT  
 Reading a file & output a file

<snip>

Quote:
> stack_list* link is more
> logical, stack_list *link is traditional.

Style wars again?

What is so logical about T* obj? Consider declaring several variables on the
same line. What happens to the logic now?

--

"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton



Thu, 22 Sep 2005 17:57:36 GMT  
 Reading a file & output a file

Quote:

> What is so logical about T* obj? Consider declaring several variables on
the
> same line. What happens to the logic now?

Thats the illogic of C.

int* ptr1, ptr2.

would declare two pointers to integers if C syntax was sensible,
unfortunately it isn't.



Thu, 22 Sep 2005 19:57:30 GMT  
 Reading a file & output a file

Quote:


>> What is so logical about T* obj? Consider declaring several variables on
> the
>> same line. What happens to the logic now?

> Thats the illogic of C.

> int* ptr1, ptr2.

> would declare two pointers to integers if C syntax was sensible,
> unfortunately it isn't.

It's perfectly sensible, you're just not reading it right.  See my post.

        - Kevin.



Thu, 22 Sep 2005 20:44:59 GMT  
 Reading a file & output a file

Quote:

> Yes, I am doing my homework. Due to my company request. I am not at my
> country side. It was telling by my classmate. Unlucky, the deadline is
> tomorrow 07/04/2003 13:00 GMT+8 by electronic submission. So, I need to
> do it ASAP. I just remain two question to finish my homework. I just get
> the only information by my classmate. I am not family with stack and link
> list. So, I got problem on the remain question. Do you have any
> information about the link list?

Are you deliberately continuing to toppost in this newsgroup to be
annoying, or are you either confused, ignorant, or thick?  If you
continue you will get plonked, and that will be the end of any
help you receive here.  One admonition should be more than enough.

--

   Available for consulting/temporary embedded and systems.
   <http://cbfalconer.home.att.net>  USE worldnet address!



Thu, 22 Sep 2005 21:01:19 GMT  
 Reading a file & output a file
Hello:

I am sorry to say that if I have make any trouble on this. But I just want to
solve the problem and want to learn more about in C Language. Does your means I
need to re-create another subject instead of continue on the reply?

    Due to my english was not enough, may be my wording are not polite. To be
honestly, I just want to get help on this newsgroup!

    Sorry for any inconvenience by make form this message!
    Sorry about that!

Quote:


> > Yes, I am doing my homework. Due to my company request. I am not at my
> > country side. It was telling by my classmate. Unlucky, the deadline is
> > tomorrow 07/04/2003 13:00 GMT+8 by electronic submission. So, I need to
> > do it ASAP. I just remain two question to finish my homework. I just get
> > the only information by my classmate. I am not family with stack and link
> > list. So, I got problem on the remain question. Do you have any
> > information about the link list?

> Are you deliberately continuing to toppost in this newsgroup to be
> annoying, or are you either confused, ignorant, or thick?  If you
> continue you will get plonked, and that will be the end of any
> help you receive here.  One admonition should be more than enough.

> --

>    Available for consulting/temporary embedded and systems.
>    <http://cbfalconer.home.att.net>  USE worldnet address!



Thu, 22 Sep 2005 21:36:33 GMT  
 Reading a file & output a file

Quote:


>> What is so logical about T* obj? Consider declaring several variables on
> the
>> same line. What happens to the logic now?

> Thats the illogic of C.

No, I think it's something - or someone - else's illogic.

Quote:

> int* ptr1, ptr2.

> would declare two pointers to integers if C syntax was sensible,
> unfortunately it isn't.

C syntax is perfectly sensible:

int *ptr1, *ptr2;

*ptr1 and *ptr2 are both ints.

Declaration follows usage, and all that.

--

"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton



Fri, 23 Sep 2005 01:35:23 GMT  
 Reading a file & output a file
On Sun, 6 Apr 2003 09:57:36 +0000 (UTC), in comp.lang.c , rjh

Quote:


><snip>

>> stack_list* link is more
>> logical, stack_list *link is traditional.

>Style wars again?

>What is so logical about T* obj? Consider declaring several variables on the
>same line. What happens to the logic now?

Bad style masks your logic fault.... :-)

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>



Fri, 23 Sep 2005 05:37:08 GMT  
 Reading a file & output a file
On Sun, 06 Apr 2003 21:36:33 +0800, in comp.lang.c , Alan Tang

Quote:

>Hello:

>I am sorry to say that if I have make any trouble on this. But I just want to
>solve the problem and want to learn more about in C Language. Does your means I
>need to re-create another subject instead of continue on the reply?

No, it means you need to write your reply BELOW the material you're
replying to, and you need to DELETE non-relevant parts of hte mesage.

Like I've done here.

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>



Fri, 23 Sep 2005 05:38:09 GMT  
 
 [ 15 post ] 

 Relevant Pages 

1. read a file than produce 2 output files(HELP)

2. read a file than produce 2 output files(HELP)

3. about bitmap file read&show&write

4. fgets reading a configuration file: compiles OK but output wrong

5. Read command output file

6. Read and Output RTF file

7. Help! reading from a file and output

8. Please Help: Reading & Writing from/to a Unicode File produces garbage in output file

9. Sorting output to diff files into a single file

10. output file as true 3-d file

11. ANSI C Run Time Erroe to output data to the output file

12. VC 5 TRACE output to a file instead of the output window

 

 
Powered by phpBB® Forum Software