C++ :: Program Crashing When Reading Text From Files
Feb 5, 2014
I'm writing a code obfuscator in C. Debugger shows no errors in the code, but the program crashes after compiling -- I'm guessing it has something to do with while loops or reading data from files.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
// list off all replaced elements
typedef struct ReplaceList {
char *from;// from string
char *to;// to string (random)
[Code] ....
View 3 Replies
ADVERTISEMENT
May 31, 2013
I want to know how to read multiple text files in this program... I have 5 text files(order1,order2,...order5).
#include<iostream.h>
#include<fstream.h>
#include<conio.h>
#include<windows.h>
using namespace std;
class{
[Code] ....
View 3 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
Dec 10, 2013
program that I am working on. I want to use fgets() in my program so I could handle multiple words from a text(to be able to handle spaces). I get a weird result when running the program.
Code: #include <stdio.h>
#include <stdlib.h>
//#include "kim.h"
#include <string.h>
[code]....
View 4 Replies
View Related
Jan 28, 2015
i am trying to doing my project what is: Diff - The program should compare two text files and list the differences, i.e. lines and columns of the beginning and the end of a given difference.
i dont know how to start or what to do with this.
View 4 Replies
View Related
Jul 9, 2013
I want to make a program that can know the current time and create a new .txt file.For example if its Monday to day then when its Tuesday it crates a new txt file called Tuesday.I really don't know how to go about this.I know i will need to use the time.h library.
View 4 Replies
View Related
Jan 29, 2013
Basically I am to create a program that will read two saved text files; one is [2x4] ~ (matrixA.txt) and another is [4x2] ~ (matrixB.txt). The program is supposed to read both text files, multiply them, and generate an output that will be saved as ~ (matrixC.txt).
So here is my horrible attempt at it:
Code:
#include <stdio.h>
int main() {
FILE * fileA;
FILE * fileB;
FILE * fileC;
[Code] .....
And these are the compile errors...
C:UsersLeDerpHW1.c: In function `main':
HW1.c:27: parse error before `int' //Line 28
C:UsersLeDerpHW1.c: At top level:
HW1.c:34: warning: parameter names (without types) in function declaration //35
HW1.c:34: warning: data definition has no type or storage class //35
HW1.c:35: parse error before `for' //37
[Code] .....
View 13 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
Oct 3, 2013
I need to decrypt my text file and make it able to read in my program..
What I have programmed so far is to read the encrypted file, create a new file, decrypt it and read the newly created file..
I need to decrypt the encrypted file without having to create a new file that reads the decrypted text..
Well, Let me show you my code:
P.S Most of the include is not needed and I already know that Visual studio 2010 Windows Form Application CLR
Code:
#pragma once
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <conio.h>
[Code].....
You have my decryption code and the code I want to use..
I have uploaded the code for you to use on your computer because it is fairly hard for me to explain..
I want to be able to read the encrypted file in my program, without having to writing a new file to decrypt it..
Decrypted & Encrypted .txt file Included (And images)
--> Program .rar pack link <--
Build it with Visual Studio 2010
View 5 Replies
View Related
Sep 5, 2013
My program is crashing when I'm trying to call b = a. What has me confused is that when I call c = d = b, it all works fine.
I actually think I see it now that I posted this. In operator= I'm changing the size, but I'm not changing the size of the array that it's pointing to correct? I'm keeping it as 'p = new T[size]' rather than changing it to 'p = new T[x.size]' correct?
#include <iostream>
#include "Array.h
int main() {
std::cout << "creating Array< int > object a ...
[code]....
View 13 Replies
View Related
Oct 13, 2014
I just finished coding a program that is based on polymorphism and inheritance but when I ran the program it crashed? I do not know what is the cause of the program crashing.
#include<iostream>
#include<string>
using namespace std;
class Shape{
float density;
[code].....
View 9 Replies
View Related
May 5, 2013
Code:
#include<stdio.h>
//bookData structure
struct bookData {
int recordNum;
char description[ 15 ];
int booksBought;
double bookCost;
[code]...
I am able to add records and show records, no problem. But when I go to delete a record, it crashes immediately after inputting the record number I want to delete. I don't see why. I've set it up exactly like the example in my book, having of course changed the variable names for my program. Does it have something to do with the pointer?
View 3 Replies
View Related
Mar 3, 2014
When I go to run the Fibonacci function ( fib ), it begins to return incorrect calculations towards the higher numbers, but then seems to correct itself for a little bit, but then does it again and ultimately crashes. And the program seems to be crashing at random numbers. Sometimes the it will make it up to F(55), other times it will only get to F(20).
Also, when I go to run the program on a Linux server, it segfaults, but it doesn't when I just run it on my IDE. the function adds two arrays with individual digits together. It does this to allow the program to add numbers that would exceed the boundaries of INT_MAX.
Here is the header file "Fibonacci.h":
Code:
#ifndef __FIBONACCI_H
#define __FIBONACCI_H
typedef struct HugeInteger
{
// a dynamically allocated array to hold the digits of a huge integer
int *digits;
// the number of digits in the huge integer (approx. equal to array length)
int length;
} HugeInteger;
}
[code]....
View 12 Replies
View Related
Oct 18, 2013
The program keeps on crashing when it finishes case 1
View 5 Replies
View Related
May 11, 2014
I was writing a program and it started crashing on exit (segment fault), after the 'return 0' in main(). I figure it's an std destructor.
I started with the program I was writing and just stripped out as much as I could, while making sure the crash persisted. If I remove any of the remaining code the crash disappears, even the seemly unrelated or scoped code.
#include <iostream>
#include <fstream>
#include <condition_variable>
#include <mutex>
#include <thread>
/* Call stack results:
[Code] ....
View 2 Replies
View Related
Jan 16, 2014
I am writing a piece of code that requires me to display the last 1000 lines from a multiple text files (log files). FYI, I am running on Linux and using g++.
I have a log file from which - if it contains more than 1000 lines, I need to display the last 1000 lines. However, the log file could get rotated. So, in case where the current log file contains less than 1000 lines, I have to go to older log file and display the remaining. For e.g., if log got rotated and new log file contains 20 lines, I have to display the 980 lines from old log file + 20 from current log files.
What is the best way to do this? Even an outline algorithm will work.
View 6 Replies
View Related
Oct 13, 2013
So this program I have to make keeps spitting out an error report when I try and run it. I am using eclipse C kepler.
The file it is supposed to read has the following text;
R1 N001 N003 20
R2 N002 N001 5
R3 N001 0 10
R4 N002 N003 10
R5 N003 N000 5
I1 0 N002 10
View 2 Replies
View Related
May 5, 2014
i have this program I am working on and it seems to crash after the function call getdata()
here is the code
#include<iostream>
#include<string>
#include<cstdlib>
[Code].....
View 1 Replies
View Related
Apr 5, 2013
I am writing a program to hide files behind other files using Alternate Data Streams in Windows NTFS file systems.
The program is as follows:
Code:
#include <stdio.h>
#include <stdlib.h>
int main(void){
char hostfile[75], hiddenfile[75], hiddenFileName[15] ;
printf("Enter the name(with extension) and path of the file whose behind you want to hide another file: ");
scanf("%75s", hostfile);
[Code]...
The complier is showing error as "Extra Perimeter in call to system" but I am not getting where?
View 4 Replies
View Related
Feb 26, 2013
How do I read a .pdf file using C++? When I try to open it using myfile.open ("example.pdf"); but all I see is some Crazy Symbols. Is there any way to open ?
View 3 Replies
View Related
Dec 22, 2014
I cant seem to read stuff in from my students.txt file which contains this
19992195 John Smith 20 05 1995 09 09 2011 15 05 2014 55 65 72 58 80 45 40 45 66 78 88 81
20051195 Mark Dobson 20 05 1995 09 09 2011 15 05 2014 55 65 72 58 80 45 40 45 66 78 88 81
20063196 Paula O'Reilly 20 05 1995 09 09 2011 15 05 2014 55 65 72 58 80 45 40 45 66 78 88 81
20053344 Aoife Cleary 20 05 1995 09 09 2011 15 05 2014 55 65 72 58 80 45 40 45 66 78 88 81
It has something to do with the lines at the bottom of the code. It doesnt cout anything. The program just crashes upon execution. First, it asks me the amount of students i want to handle. I enter '1'. Then it asks me if i want to read in from external file and i enter 'Y'. then the exe just crashes
#include <iostream>
#include <cstddef>
#include <cstdlib>
[Code]......
View 3 Replies
View Related
Feb 20, 2015
I have to write a program that sorts names and grades from a file and output them to another.
For example:
Name: Peter Parker
Exam 1: 95
Exam 2: 90.625
Exam 3: 91.20
Name: Mary Smith
Exam 1: 65
Exam 2: 79.1234
Exam 3: 70.24
Becomes something like this in the output file:
Name: Parker, Peter
Average Score: 92.28
Grade: A
Name: Smith, Mary
Average Score: 71.45
Grade: C
I know I'm supposed to read the whole file, but I'm getting really confused on how to take the name of each student separately without recording Exam 1, 2, and 3. I'll be able to do the average score and grade on my own.
View 2 Replies
View Related
Jan 28, 2014
Is there a way to indicate how many records exist in a given file? For example, vectors have the vector.size() command to show the number of given elements. Is there a such command for files and records?
View 6 Replies
View Related
Oct 3, 2014
The directions are to write a program that reads sorted integers from two separate files and merge the contents of the file to an output file (third file). The only standard output will be any errors to be reported and a “FINISHED” statement after all items have been processed.
file1.txt
2
4
6
8
10
file2.txt
1
5
11
12
15
Output.txt
1
2
4
5
6
8
10
11
12
15
This is the code I have so far, but it is not working, and I have put the two txt files in the same directory as my .cpp file. It is not working though still. What have I done wrong and how can I fix it to read these integers from the two numbers and merge the contents into a third file?
#include <iostream>
#include <fstream>
using namespace std;
int main() {
int num1;
int num2;
ifstream inputFile;
[Code] ....
View 5 Replies
View Related
Mar 24, 2014
My question portion is attached. The code I have written is below.
#define _USE_MATH_DEFINES // for C++
#include <cmath>
#include <iostream>
#include <iomanip>
[Code].....
View 3 Replies
View Related
Jan 16, 2015
I'm messing around with reading and writing files. The first file creates a small txt file. Simple enough
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(){
string name;
string desc;
[Code] ....
It does what it should. It creates a text file "items.txt" .... It reads as such:
dagger,a dagger,15,10,0,1,3,1,0,0,0,1,0,0,0,0,0,1
The second file is meant to read the file and place the data back into the variables. This happens, but the data crams itself into the first variable, and the rest of them collect the trash that's in memory.
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main() {
string name,desc;
[Code ....
I need to get "dagger" into name, "a dagger" into description, and each value with their perspective variable. I'm sure I need some type of "separator". Hopefully I can use the comma. Before it's over, I will have about a hundred items that will need to be read into a class of items.
View 4 Replies
View Related