![]() |
|
#1
|
|||
|
|||
not opening file correctlyHi all!
Let me try to explain what my problem is... I'm trying to create a program that opens a file containing a word list (words.txt), and then open some logfile(s)... I'm using command-line arguments to pass the names of the logfiles... Now for the problem: When i'm using it from within dos, and passing logfiles as parameters everything works fine... But for some reason when i drag & drop logfiles over to my app icon, it seems to open words.txt, but it doesn't read anything from it (looking at WX/WY). It does however, correctly open and read the files dragged into my app... Does anyone know what is causing this strange behaviour or know a way around this problem?? Thanks in advance! Heres the code: BTW i'm using bcc32, i've also tried it in dev-c++ but it made no difference... CPP / C++ / C Code:
|
|
#2
|
||||
|
||||
|
Quote:
My initial guess is: CPP / C++ / C Code:
Add more output statements to see what's happening. Also system("pause"); is an improper way to pause your program. Check this tutorial for better options. __________________
Got a cough? Go home tonight and eat a whole box of Ex-Lax. Tomorrow, you'll be afraid to cough. -- Pearl Williams |
|
#3
|
|||
|
|||
|
Quote:
The expression "strange behavior" is somewhat subjective. I'll comment on the last issue first: It's a command line program; run it from a command line. As for the rest: Make the program tell you what's happening. For example, how do you expect a program to get the names of several arguments by dragging and dropping onto its icon? (That is not a rhetorical question; I really don't know the answer.) You can try something like this and experiment with it. As soon as you drop a file onto the program icon, the program begins execution, right? Then what? CPP / C++ / C Code:
Sometimes when I have trouble opening files, I do something like the following to make sure the program is looking in the right directory. CPP / C++ / C Code:
If you think the file is being opened correctly but don't know if the program is reading anything, print out each line as it is read (start with a small file with only a few words). Something like this: CPP / C++ / C Code:
Get the idea? Once the program is up and running, if you don't see what you expect, make it tell you what's happening. Regards, Dave |
|
#4
|
|||
|
|||
|
Quote:
Well, for Windows users, that's kind of a simple question with a simple answer. So, I'll share what I found out in my own simple way. Using Windows Explorer, I made a desktop shortcut to the executable. Then, again with Windows Explorer, I selected three text files and dragged-and-dropped them to the desktop icon. File "words.txt" was in the same directory as the executable. The program opened and read the words.txt file. The other files showed up as arguments 1, 2, and 3 and the program printed the first line of each. I have never done this before (drag-and-drop files to an icon for a command line program), since I (almost) always work from a command line. Anyhow, now that I can see it works for me, the previous suggestions that I made should let you see what's happening with yours. Regards, Dave I wish that I could say that, "I learn something new every day," but according to my recent logs, I have been learning something new about every 12.3 days. Unfortunately, my short-term memory seems to have a half-life of about 6.15 days. The odds that it will stick until the next new thing: something worse than 50-50. |
Recent GIDBlog
Writing a book by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Airport Log program using 3D linked List : problem reading from file | batrsau | C Programming Language | 11 | 29-Feb-2008 08:44 |
| CD burner wont burn!! | robertli55 | Computer Hardware Forum | 1 | 18-Jun-2004 11:53 |
| Yet another CD burner problem: Lite-On LSC-24082K | Erwin | Computer Hardware Forum | 1 | 22-May-2004 12:28 |
| Re: Programming Techniques | WaltP | C Programming Language | 0 | 10-Mar-2004 00:56 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The