C :: Program That Takes A Large Text File As Input
Nov 7, 2014
I am writing a spell checker for a exercise for a class I am taking online. I have to load a huge text file of 143092 words into a hash table.
The program segfaults on word number 63197. Is there a way to debug this in gdb without having to step threw the function 63197 times.
View 3 Replies
ADVERTISEMENT
Jan 15, 2013
A program which takes input from user and write it to a file then it reads data from that file then it should search for specific data such as email adresses or url etc.
View 1 Replies
View Related
Jan 1, 2014
I am currently working out on a problem in which a c program is to be made which shows a large text file in parts.
f
For example: If file contains 200 lines. 50 lines will be shown on first page and user is asked to press any key to move to next page until EOF is found. user is allowed to return to previous page as well, and this is very complicated task for me. I tried to move cursor to a specific position using fseek etc but it page doesn't stop and reaches to end quickly.
View 1 Replies
View Related
Jul 27, 2013
I have to make a program that takes a number input from the user and prints the corresponding fibonacci sequence number. For example, for the input of 3, it should print 2 since the third term in the fibonacci sequence is 2.
I am not sure how to do this so for my attempt, I used the formula found in this website. A Formula for the nth Fibonacci number
Here is the program so far. It doesn't produce the correct output.
Code:
#include <stdio.h>
#include "genlib.h"
#include "simpio.h"
#include "math.h"
[Code]....
View 11 Replies
View Related
Jan 20, 2013
I am writing a C++ program which takes date & time input from the user. This is then parsed into a struct such as:
struct time
{
short year;
short month;
short day;
short hour;
short min;
};
My question is: how can I convert such a struct into a time_t object, which is an unsigned long giving the time as the number of seconds elapsed since the epoch Jan 1st 1970, 00:00, as set out in time.h.
I am wondering if this can be achieved using the standard library, or whether I just need to write a function to perform the appropriate arithmetic.
View 2 Replies
View Related
Dec 30, 2012
What I'm trying to do is make a calculator that takes two large numbers in a linked list then ask the user if they wish to add them or subtract them.
#include<iostream>
#include<string>
using namespace std;
class Node {
public:
int value;
Node * next;
[Code] ....
View 5 Replies
View Related
Jan 23, 2015
I'm trying to create a program that takes an integer input and displays each digit on a new line from right to left.
An example of this would be:
Enter an integer: 657
Digit (1): 7
Digit (2): 5
Digit (3): 6
So far I have this:
#include <stdio.h>
#include <math.h>
int main() {
int i, input, output;
printf("Enter an integer: ");
scanf("%d", &input);
if(input == 0)
printf("Digit (1): 0");
[Code] ....
It works perfectly fine, but I just learned that I am not allowed to use the #include <math.h> so I have to take out floor, log, and pow.
I'm pretty sure I have to do some sort of while or for loop to get the results, but how to do it.
View 6 Replies
View Related
Feb 10, 2013
I have a massive text file containing many thousands of directory and file names with / at the root, like so:
/dir/
/dir/dir/
/dir/dir/dir/
/file
/dir/file
/dir/dir/file
/dir/dir/dir/file
I need to parse the file in such a way that I can create a filesystem hierarchy as if I were enumerating files/directories. Ultimately I want to add these to a tree gui control with everything under its proper node without duplicating anything. It should look roughly like so:
dir
-file
-dir
-file
-dir
-file
I can open the file and add nodes/children to the tree control but how should I go about doing the actual parsing? How can I find a filename and say "this belongs under this node"? I want to do this efficient as possible even if I must use multiple threads.
View 1 Replies
View Related
May 12, 2014
I'm having the upmost hardest time doing this program that basically validates the user's input with a text file. The text file is like so and below that is the work I have so far...
"user1"
"pass1"
"user2"
"pass2"
etc!
[Code].....
View 2 Replies
View Related
Apr 3, 2015
I need to write a program that reads four float numbers from the input.txt file, then it prints out the greatest of the four numbers into the output.txt file. I did everything, but the numbers don't print out.
#include <iostream>
#include <fstream>
using namespace std;
int main() {
ifstream inFile;
ofstream outFile;
float number1, number2, number3, number4;
[Code]...
View 2 Replies
View Related
Jan 30, 2013
I'm trying to make a program that you input your login info and it writes that info to a text file. Then, later on once I get my problem fixed, the program will read the info to the user. my code is as follows(the input part is a bit lengthy):
// Password Log
#include <iostream.h>
#include <fstream.h>
#include <string>
#include <time.h>
using namespace std;
ofstream login;
[Code] ....
What my problem is when I choose "Input new login info" it automatically inputs I have no clue, and calls next program.
View 3 Replies
View Related
Feb 23, 2013
I'm writing an addition and subtraction calculator that takes input as: 5+6-3+2. You should be able to add or sub as many numbers as you want. I want the while loop to stop when the user hits enter. I put the getchar() function to catch the and break the loop but it is also swallowing the '-' sign, which I want to use to subtract and is instead adding the numbers with "sum+=number". How can I get around that?
Code:
#include <stdio.h>
int main(int argc, char *argv[]){
int number, sum = 0;
[Code]....
View 3 Replies
View Related
Feb 13, 2014
I have a menu for a project that takes a string input and does whatever option you specify. It works perfectly EXCEPT when it goes through the while-loop (while you didn't say quit the menu reloads). It will spew out all the text in the menu like a bulimic teenager. Then it reloads properly and asks you for an input like nothing happened. While this is not a fatal error (code still functions)...
Code:
#include <stdio.h>
#include <math.h>
#include <string.h>
double aa=0, ab=0, ac=0, sa=0, sb=0, sc=0;
char a1[13], o1[]="AAS
[Code] .....
View 2 Replies
View Related
Jun 5, 2014
I want to make a program that opens a text file and checks the usernames listed in the text files to see if the names are registered on a site such as twitter. How easy would this be to make, what things would I need to know?
View 4 Replies
View Related
Apr 20, 2014
Write a function that takes two input arguments and provides two separate results to the caller, one that is the result of multiplying the two arguments, the other the result of adding them.Since you can directly return only one value from a function, you'll need the second value to be returned through a pointer or reference parameter.
Code:
#include "Code.h"
#include <iostream>
#include <string>
double x, y;
[Code] ....
View 3 Replies
View Related
Dec 7, 2012
How do I Write a function that takes two linked list as input arguments these linked list contain numbers like this:
num1->3->5->2->NULL (assuming that number 1 is 352)
num2->4->3->9->1->NULL (assuming that number 2 is 4391)
The function should return 1 if num1 points to a linked list which represents a smaller number than the number pointed to by num2 linked list. Otherwise, it returns -1. If both linked list point to exactly the same number, returns a 0.
View 3 Replies
View Related
Jan 25, 2015
So the question is this [URL] .....
My code is this:
#include <iostream>
#include<cmath>
using namespace std;
int main(int argc, char *argv[]) {
long double div;
//div=((1e+9)+7);
[Code] .....
The problem is when the hackerrank inputs the following:
10
5351871996120528
2248813659738258
2494359640703601
6044763399160734
3271269997212342
4276346434761561
2372239019637533
5624204919070546
9493965694520825
8629828692375133
My code gives the wrong output.
The output is supposed to be
578351320
404664464
20752136
999516029
743537718
323730244
174995256
593331567
136582381
305527433
So what changes should I make to get my code give the correct output.
View 9 Replies
View Related
May 10, 2013
This is a small program that reads a line from the screen, takes the ASCII values from the entered text, and edits it. Next, the ASCII values are reinterpreted (am i misspelling?) as text, and displayed. However, my final output has (allways?) at least 7 characters, even if you enter only one. I'm also trying to accomplish, that the part of the string which isn't filled, will be printed empty. In spaces.
compiled with -std=c99.
Code:
#include <stdio.h>
int main(){
int maxsize;
printf("How long is your message?
[Code] .....
View 6 Replies
View Related
Mar 31, 2014
I am creating a simple log parser (loads a text file and filters out unnecessary information, but has the option to show the full log) and I'm running into an issue with fairly large log sizes (50+mgs). I have seen a few recommendations from a stream to memory manged files and even alternate 3rd party controls.
I foresee a few issues with any of the non-third party solutions (which I would prefer to avoid third-party add-ins) such as the scroll bar not correctly reporting the relative length or position of the complete text in the box (when displaying only a portion of the file at a time) and in the stream solution where you read on scroll (as necessary) have not only the same issues, but how do you resume reading in the middle of the file? This also all assumes I would be periodically clearing the RichTextBox to keep the memory usage down to avoid an OutOfMemoryException (which I have been running into.)
View 14 Replies
View Related
Sep 22, 2013
I need to write a program to make the user input some text, and the first letter of each word has to be uppercase. (have to use while loops)
So for example lets say the user inputs:
i lOvE pRoGrAmMiNg
The output needs to be:
I Love Programming
Code: int main()
{
char c, lower_c;
printf("Enter Text");
while (c != '' && c >= 0)
{
if (c >= 'A' && c <= 'Z')
lower_c = c + 32;
else
lower_c = c;
[Code]...
I have started this code by making the letters lowercase (I don't know if this was the right way to approach this, ). I am not sure how proceed after this step, the step of making the first letter uppercase. (PS for the program, loops should be while loops)
View 6 Replies
View Related
Nov 23, 2013
I am trying to make a simple program, I would like it to be able to do the following, Write a program that opens two text files (input1.txt and input2.txt) for input .The program should write the followings in the two files. input1.txt:
This is the first line in input1.txt.
This is the second line in input1.txt.
This is the third line in input1.txt.
This is the fourth line in input1.txt.
input2.txt:
This is the first line in input2.txt.
This is the second line in input2.txt.
This is the third line in input2.txt.
What would be the best way to go about doing this? I wrote the program below, but I don't think that it works.
#include <iostream>
#include <fstream>
#include <string>
int main()
{
using namespace std;
string input1;
[Code]...
View 2 Replies
View Related
Jun 12, 2013
int main()
{
string line;
int i,ch;
[Code].....
View 1 Replies
View Related
Mar 21, 2012
Code:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main() {
ifstream wormfile("worm.txt");
ofstream dtfile("dt.txt");
[Code] ....
worm.txt has
Code:
I like pie
I like rice
and I like applesauce
while dt.txt has nothing
I was able to get the lines in worm.txt and get it to copy the lines to dt.txt BUT it looks like I can do this in some kind of if statement or while loop. The reason why I don't like to do it the way its in the code because I could have another file that has the lines that I don't know and the code comparing them would take less time then me looking at the file, counting the lines and putting x lines of getline functions in the code.
View 2 Replies
View Related
Feb 20, 2015
I am trying to get user's voice as an audio input to a c++ program and store it in a text file (.txt)
I have been searching over the web to find some kind of library or something like OpenCV(video library) for while now but nothing seems to be there.
View 2 Replies
View Related
Mar 24, 2013
Why my output screen for this program does not want to stay open. It only opens for a split of a second and it's gone. The program is supposed to take numbers from a input file and display and save the manipulation in the output file. Here is the program.
Code:
#include<iostream>
#include<fstream>
#include<iomanip>
usingnamespace std;
[Code] ....
View 6 Replies
View Related
Nov 12, 2013
i am doing some practice problems and i can't seem to figure out how to do this. basically we have a students number of test scores, then the name followed by the scores they have in a text file. Then we have to make a class with a constructor, copy constructor, destructor, and overload the = operator and the input and output operator. Are we suppose to call the text file in the input overload operator?
Here is what i have so far.
This is my header file.
#ifndef STUDENTTESTSCORES_H
#define STUDENTTESTSCORES_H
#include <string>
#include <iostream>
using namespace std;
class StudentTestScores{
private:
string studentName;
[Code]...
i am 100% sure the overloading the input is wrong
here is the implementation of the constructor copy constructor and desctructor
#include <iostream>
#include "StudentTestScores.h"
using namespace std;
StudentTestScores::StudentTestScores(string name = "", int numScores = 0)
{
studentName = name;
numTestScores = numScores;
if (numScores <= 0)
testScores = NULL;
else
[Code]...
and here is the notepad file
3
Justin Bieber491.469.184.681.081.5
Miley Cyrus380.080.090.083.3
Kim K490.575.661.481.677.2
The program is suppose to use all the information and read from the notepad and output the exact things as the notepad file
View 7 Replies
View Related