LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 12-05-2006, 06:00 PM   #1
manolakis
Member
 
Registered: Nov 2006
Distribution: xubuntu
Posts: 392

Rep: Reputation: 30
Problem with writing in a text file in C


Hey there
It will be great if someone could help me with the following case
I recently found a C program on the net and i compiled and everything was fine
The program starts by passing parameters in the terminal a text file to read and another to write. Well, reading goes well. The problem is there is nothing in the output text file. I checked my permissions which were good as well.
Any ideas?
 
Old 12-05-2006, 06:12 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,005
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
Might help to see the relevant piece of code? :}


Cheers,
Tink
 
Old 12-06-2006, 10:08 AM   #3
manolakis
Member
 
Registered: Nov 2006
Distribution: xubuntu
Posts: 392

Original Poster
Rep: Reputation: 30
Well, to be honest with you i thought about it before.
The fact is that the code is too long and is regarded to Counter Propagation Neural Networks in Artificial Intelligence so that's why i didnt post it.
http://www.cis.syr.edu/~mohan/html/Bookfiles/counter.c
There is also a README txt in http://www.cis.syr.edu/~mohan/html/B...ME-for-counter which i strongly believe that it would be useful.
 
Old 12-06-2006, 11:19 AM   #4
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
You need to pass three files in total. Sounds like you only pass two.
 
Old 12-06-2006, 11:32 AM   #5
manolakis
Member
 
Registered: Nov 2006
Distribution: xubuntu
Posts: 392

Original Poster
Rep: Reputation: 30
The fact is that in output generation (-o) i pass 3 files as i am told
I noticed also that if i pass an output file which doesnt exist after the compilation will be produced, but will not be opened by a default program lets say by KWrite.
If i try then to open it with KWrite will be empty.
 
Old 12-06-2006, 11:18 PM   #6
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
It works (at least my outputfile is not empty). I started with an empty data file before I could generate the weight file. Next it went smoothly.
Code:
wim@btd-techweb01:~/progs/lq507750$ ./lq507750 -o weight1 data1 out1
Unable to open file weight1 for reading
wim@btd-techweb01:~/progs/lq507750$ ./lq507750
** Select L(earning) or O(utput generation) **
L
How many dimensions does the input pattern have?: 2
How many dimensions does the output pattern have?: 3
How many hidden nodes will the network use?: 4
Enter the name of the training data file: data1
Unable to open file data1 for reading
wim@btd-techweb01:~/progs/lq507750$ touch data1
wim@btd-techweb01:~/progs/lq507750$ ./lq507750
** Select L(earning) or O(utput generation) **
L
How many dimensions does the input pattern have?: 2
How many dimensions does the output pattern have?: 3
How many hidden nodes will the network use?: 4
Enter the name of the training data file: data1
Enter the name of the output weight file: weight1
Total number of input samples?: 5
Max number of iterations in phase 1(enter a positive integer)?: 6
Max number of iterations in phase 2(enter a positive integer)?: 7
Enter 0 to use default values for learning rate parameters, enter 1 for user-specified values
  (default learning rates decay exponentially from 0.3 to 0.01): 0
Elapsed time 0 milliseconds

wim@btd-techweb01:~/progs/lq507750$ ./lq507750 -o weight1 data1 out1
Elapsed time 10 milliseconds
wim@btd-techweb01:~/progs/lq507750$ ls -l
total 92
-rw-r--r--  1 wim develop     0 2006-12-07 05:54 data1
-rwxr-xr-x  1 wim develop 23400 2006-12-07 06:03 lq507750*
-rw-r--r--  1 wim develop 22390 2006-12-07 06:03 lq507750.c
-rw-r--r--  1 wim develop 40000 2006-12-07 06:05 out1
-rw-r--r--  1 wim develop   194 2006-12-07 06:05 weight1
wim@btd-techweb01:~/progs/lq507750$
There are a number of warnings when using the -Wall option when you compile the source code. You might want (or have to) to clear them out first.

PS gcc 3.3.4 on slackware 10.1

Last edited by Wim Sturkenboom; 12-06-2006 at 11:24 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
writing text to the beginning of a file linuxmandrake Linux - Newbie 3 03-26-2006 11:55 PM
vb.net writing to a specific line in a text file mrobertson Programming 3 12-30-2005 11:24 PM
Writing to a specific line in a text file mrobertson Programming 6 12-30-2005 05:02 PM
vb.net reading and writing to a text file simultaneously mrobertson Programming 3 09-08-2005 01:30 PM
Writing to a text file vb.net mrobertson Programming 5 08-04-2005 01:37 PM


All times are GMT -5. The time now is 09:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration