User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 402,860 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,943 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser: Programming Forums
Views: 2587 | Replies: 58 | Solved
Reply
Join Date: Aug 2005
Posts: 4,716
Reputation: iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light 
Rep Power: 17
Solved Threads: 312
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Industrious Poster

Re: Help needed with loop.

  #31  
Nov 24th, 2007
Is your file called data.txt or data.text

And did you remember the double backslash after the c:\\
Member of: F-ugly code club

Join today don't delay!
Reply With Quote  
Join Date: Nov 2007
Posts: 31
Reputation: r5ingh is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
r5ingh r5ingh is offline Offline
Light Poster

Re: Help needed with loop.

  #32  
Nov 24th, 2007
its .txt. (that was a typo before) and yes i remmeberd the escape character too

Last edited by r5ingh : Nov 24th, 2007 at 2:34 pm.
Reply With Quote  
Join Date: Aug 2005
Posts: 4,716
Reputation: iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light 
Rep Power: 17
Solved Threads: 312
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Industrious Poster

Re: Help needed with loop.

  #33  
Nov 24th, 2007
hmm, ok go to

start > run then type cmd then click ok

In command prompt if it isn't already pointing and c:\>

keep typing cd.. <enter>
until you get there.

When it is pointing at c:\> type in dir and tell me if you see data.txt listed there?

I have a suspicion it will show data.txt.txt
Last edited by iamthwee : Nov 24th, 2007 at 2:37 pm.
Member of: F-ugly code club

Join today don't delay!
Reply With Quote  
Join Date: Aug 2005
Posts: 4,716
Reputation: iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light 
Rep Power: 17
Solved Threads: 312
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Industrious Poster

Re: Help needed with loop.

  #34  
Nov 24th, 2007
well?
Member of: F-ugly code club

Join today don't delay!
Reply With Quote  
Join Date: Aug 2005
Posts: 4,716
Reputation: iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light 
Rep Power: 17
Solved Threads: 312
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Industrious Poster

Re: Help needed with loop.

  #35  
Nov 24th, 2007
Okay I know what you've done. Go to the text file click rename then delete the .txt you have there.
Member of: F-ugly code club

Join today don't delay!
Reply With Quote  
Join Date: Nov 2007
Posts: 31
Reputation: r5ingh is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
r5ingh r5ingh is offline Offline
Light Poster

Re: Help needed with loop.

  #36  
Nov 24th, 2007
ah fixed the issue!
i can see it works now.
Reply With Quote  
Join Date: Nov 2007
Posts: 31
Reputation: r5ingh is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
r5ingh r5ingh is offline Offline
Light Poster

Re: Help needed with loop.

  #37  
Nov 24th, 2007
thanks appreciate the help i'll try to incorporate this into the program now
Reply With Quote  
Join Date: Aug 2005
Posts: 4,716
Reputation: iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light 
Rep Power: 17
Solved Threads: 312
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Industrious Poster

Re: Help needed with loop.

  #38  
Nov 24th, 2007
Right now is it necessary for the user to type the path at the command prompt? If it is let's try and get that working first.
Member of: F-ugly code club

Join today don't delay!
Reply With Quote  
Join Date: Nov 2007
Posts: 31
Reputation: r5ingh is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
r5ingh r5ingh is offline Offline
Light Poster

Re: Help needed with loop.

  #39  
Nov 24th, 2007
  1. { char path[150];
  2. fputs ( "Please Enter The Path Of The File You Would Like To Read From: ", stdout );
  3. gets(path);
  4. fflush ( stdout );
  5.  
  6. FILE *fp;
  7. char buf[BUFSIZ] = "crrrrrapppp";
  8. int i;
  9.  
  10. if ((fp = fopen(path, "r")) == NULL)
  11. {
  12. perror (path);
  13. return (EXIT_FAILURE);
  14. }
  15.  
  16. i = 0;
  17.  
  18. while (fgets(buf, sizeof(buf), fp) != NULL)
  19. {
  20. printf ("Line %4d: %s", i, buf);
  21. i++;
  22. }
  23.  
  24. fclose(fp);
  25.  
  26. putchar('\n');
  27. return(0);
  28. }


Got that working now mate... User can define the path! Why is the BUFSIZ defined as Crrraaap? ... i dont have any uderstanding of this.
Last edited by r5ingh : Nov 24th, 2007 at 2:45 pm.
Reply With Quote  
Join Date: Nov 2007
Posts: 31
Reputation: r5ingh is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
r5ingh r5ingh is offline Offline
Light Poster

Re: Help needed with loop.

  #40  
Nov 24th, 2007
1>: error C2664: 'encode' : cannot convert parameter 1 from 'char [512]' to 'char'

im trying this:
  1. void file() {
  2. FILE *fp;
  3. char buf[BUFSIZ] = "crrrrrapppp";
  4. int i;
  5.  
  6. if ((fp = fopen(MYFILE, "r")) == NULL)
  7. {
  8. perror (MYFILE);
  9. }
  10.  
  11. i = 0;
  12.  
  13. while (fgets(buf, sizeof(buf), fp) != NULL)
  14. {
  15. printf ("File Contains: %s", buf);
  16. i++;
  17. }
  18.  
  19. putchar ('\n');
  20. encode(buf);
  21. fclose(fp);
  22.  
  23. }

im guessing that it cannot convert the string because encode takes characters.
Last edited by r5ingh : Nov 24th, 2007 at 2:51 pm.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the C Forum

All times are GMT -4. The time now is 1:20 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC