I have designed a linklist based BookStore in which book's attributes will be stored in a node & so on. Plus at the end of program, I have to save all database into text file *(I tried binary reading but damn I got me killed & couldn't do it)* & then reload all info, of each book one by one & store it in nodes & re-make the LinkList. Now saving is done & no issue at all. *But Im having issues in reading from text file.* **Saving structure in file is:::** BookID(int) - BookName(string) - Author(string) - BookType(string) - …

Member Avatar
Member Avatar
+0 forum 5

package furniture; import java.io.*; import java.util.*; public class Program3 { public static void main(String[] args) { //array of 10 Furniture object references String[] furniture = new String[10]; String filename = "furnitureData.txt"; Scanner input = null; try{ input = new Scanner(new File(filename)); }//end try catch(FileNotFoundException e){ System.err.println(e); System.exit(1); }//end catch }//end main } with this i can not figure out why it is throwing an error that says "java.io.FileNotFoundException: furnitureData.txt (The system cannot find the file specified) Java Result: 1 BUILD SUCCESSFUL (total time: 3 seconds)" I get it is saying it can't find the file and the name is spelt …

Member Avatar
Member Avatar
+0 forum 13

Hi, just a quick question. if i have an input file with 6 lines of data. for example(ingnore the numbers 1 to 6, they indicate the file number and is not part of the file physically) 1. Peter 3 / + - * 2. Dahne 8 + - / * 3. Renee 7 - * + / 4. Charl 1 * / + - 5. Johan 2 / - * + 6. Sipho 4 * - / + my question is, how do i go about firstly extracting data for example string name= peter int combo = 3 char op …

Member Avatar
Member Avatar
+0 forum 2

[CODE]#include <iostream> //standard input and output #include <fstream> //file input and output #include <string> //for strings #include <exception> //catches exceptions #include <sstream> //stringstream comes from here #include <algorithm> #include <stack> #include <queue> using namespace std; bool writeFile(const string &data); //writes strings to file bool readFile(); //read file bool palin(const string &data); bool operator==(const stack<char>&, const queue<char>&); bool operator!=(const stack<char>&, const queue<char>&); void menu(); //display menu of choices int main(int argc, char *argv[]) { stack<char> *s; queue<char> *q; string input; string::iterator i; menu(); //launch menu return 0; } bool palindrome(const char word[], int size) { return equal(word, word+size/2, std::string(word, word+size).rbegin()); } …

Member Avatar
Member Avatar
+0 forum 1

I am writing a spellchecker program and have some issues. First thing is that I need to make better use of the memory. My code iterates through a large dictionary file repeatedly. I know its better to read this into memory first then iterate through the block but I really don't know how. The search should be optimized. The other problem is ignoring the non alphanumerical characters in the problem. Would really appreciate some help with this. [CODE]#include <stdio.h> #include <string.h> #include <stdlib.h> int main(void) { /*Open files and test that they open*/ FILE *fp1; FILE *fp2; char fname[20]; char …

Member Avatar
Member Avatar
+0 forum 6

I was supposed to write a program that reads and writes phone numbers of people to a file called phones.txt. The reading part works. The write part doesn't. I tried to use the cat command because I thought doing cat >> file.txt would simply append to a file. What it does instead is rewrite the file with the line going in twice. Heres the code: #!/bin/bash num=$# ch=3 cn=1 if [ $num -eq $ch ] then n="new" if [[ $1 == $n ]] then nfile="phones.txt" echo "$2\n$3\n" | cat >> $nfile #right here else echo "wrong parameter" fi elif [ …

Member Avatar
Member Avatar
+0 forum 6

I cant seem to save these data correctly I have mainly doubles and strings, I am saving these in a .txt file called "autosAudi.txt", I get these weird codes and boxes and sometimes for whatever reason Chinese in my textfields? Here is a example of what appears: [url]http://www.flickr.com/photos/63259070@N06/6449175293[/url] as you can see these weird boxes appear out nowhere I didnt register nothing like that, the way I navigate through the data is by clicking >> (next) or << (previous) and the information is supposed to change, the textfield next to "Numero" is supposed to give me a way to input …

Member Avatar
Member Avatar
+0 forum 5

I'm having trouble writing binary data out to a file. My end goal is to add a chunk to a PNG file; which has a format of: length (4 bytes), type (4 bytes), data (lots of bytes), crc32 (4 bytes). Collecting each of these pieces is not a problem, but when the chunk is inserted, each item gets a "\n" (0x0a) appended to it, and the numeric items (length, crc32) get written as strings instead of just their numeric values. [CODE] f = open('output.png', 'wb') f.write(prependBytes) f.write(fileLength) f.write(pngChunk) f.write(fileData) f.write(fileCRC32) f.write(appendBytes) f.close() [/CODE] How do I get the numeric values …

Member Avatar
Member Avatar
+0 forum 3

[CODE] ifstream in_gradebook; ofstream out_gradebook; in_gradebook.open("gradeBook.txt"); out_gradebook.open("gradeBook_edit.txt"); while (???) //while int is being read { in_gradebook >> score; out_gradebook << score << " "; sum = sum + score; } average = sum / 10.0; out_gradebook << average << endl;[/CODE] Here is a small snippet of the code I have trouble with. My professor told me there's a way to end the loop when the input from in_gradebook is no longer type int, which I have no idea how to do. Basically, my loop goes on forever because the variable score gets the [U]string[/U] FIRST_NAME_2 of the second line. What …

Member Avatar
Member Avatar
+0 forum 5

Is it possible to write to an existing text file in a jar. I managed to read from it with getResource() but I am stuck trying to write to it, it gives me a file not found exception. Thanks

Member Avatar
Member Avatar
+0 forum 2

Hi All, I am currently trying to figure out to finish this project. Below is my code that I have so far. There are some blank methods that I am not sure where to even begin on how to complete them. I have a description of what the methods should do above them, so please help guide me on the blank methods so I can figure them out. Part of what is confusing to me is how to get the data that is read from the file and use it in the conversions since some of the data is inputted …

Member Avatar
Member Avatar
+0 forum 126

In writing a logging program for a SDK Engine, I have come across some problems. The logging function works fine when called with test programs, but when I run it in a full test of the SDK Engine, no file is ever created. I added some testing lines to make sure the function is getting called, and it is. The directory was properly created the first time I ran the program, but the file never is. Strange thing is, the file [ICODE]failbit[/ICODE] flag is never set, and the [ICODE]is_open()[/ICODE] function returns true, but the file does not exist. Here is …

Member Avatar
Member Avatar
+0 forum 2

From a text file, i should get the necessary information in order to create a beat map, a representation of what we see in music sheets, from this text file: [CODE]3 measures 3 4 time signature 4 beats 4 note, measure 1 3 note, measure 1 1R rest, measure 1 4 note, measure 1 4 4 time signature 1 beat, measure 1 0 note, measure 1 2 4 time signature 1 beat, measure 1 1R (corresponds to the half rest)[/CODE] How do I determine the number of measures[Line 1], the time signature of each measure[LINE 2,8,11], the number of beats …

Member Avatar
Member Avatar
+0 forum 1

I am writing a program that writes log entries to an external text file and returns them upon request. When called, the return function should output the log entries between two user- submitted dates or outputs the last 100kb of the file if that's what's requested. The logfile stores each entry like: [ICODE]YYYY-MM-DD Logmessage[/ICODE] But I can't get my program to compare only dates. It compares each string it grabs, and when it compares text to a date, it doens't behave properly. Here's the code: [CODE]int returntouser() { std::stringstream returnstr; std::string begdate, enddate; int validdate = 0; while (validdate == …

Member Avatar
Member Avatar
+0 forum 1

Hey guys, I'm working on a project to use Huffman trees to compress a text file into binary. For instance, based on the frequency of the characters in a string like "aardvark", a - 3 r - 2 d - 1 v - 1 k - 1, compression using a Huffman tree could look something like 001011011100101111, assuming that the most frequent character (a) would be stored using the least number of bits (0), and one of the least frequently occurring characters (k) would be stored with the most number of bits (1111), and so forth. I am able to …

Member Avatar
Member Avatar
+0 forum 2

Hello, My friend gave me a code to try a bit. What it does is that it gets a text and format it. Here it is: [code]function boldAndItalicize(text) { return text.replace(/&/g, '&').replace(/</g, '<') .replace(/(\*+)([^*]{1,1024})(\*+)/g, function (whole, open, content, close) { if (open.length === close.length) { switch (open.length) { case 1: return '<i>' + content + '</i>'; case 2: return '<b>' + content + '</b>'; } } return whole; }); }[/code] But I want to know how I could input a plain text file(like [ICODE]test.txt[/ICODE], that is on the same folder as the script) in the [ICODE]text[/ICODE] parameter? Best Regards, Nathan …

Member Avatar
Member Avatar
+0 forum 1

The End.