Visual C++ :: Loading A File And Indexing Line Starts
Jun 14, 2013
I've spent some time trying to performance test various methods of loading / accessing a file, either into memory or through a memory mapped file, but I am having some trouble.
FILE * pFile;
std::ifstream ifs;
MapViewOfFile
I'm have trouble because Windows appears to cache the file, so I am getting very mixed results. Sometimes a huge file (100's MB's) will load quickly, other times almost instantly.
How to stop Windows from doing whatever it's doing, so I can see the real time taken to load/access a file from disk?
View 8 Replies
ADVERTISEMENT
Apr 24, 2013
I have a function and i want to delete a file when the function is called and starts it's loop i have used this code but unfortunately the file is not deleted ?
Code:
void evaluate(void) /*evaluate the population */{
int mem;
int i;
double x[NVARS+1];
char buffer[101] = {"save.txt"};
[Code] .....
View 7 Replies
View Related
Jun 29, 2013
I want to read a file and replace a particular line in a file.
Ex:
temp.txt file contains below
FilePath1: xxxxxxxxxxxxxxxxxxxxxxxxx
FilePath2: xxxxxxxxxxxxxxxxxxxxxxxxx
FilePath3: xxxxxxxxxxxxxxxxxxxxxxxxx
Mode: 1
Here My requirement is replace the 4th line Mode: 2 instead of Mode: 1.
I was used seek method like below,
Code:
CStdioFile SaveFile;
CString strFilePath;
strFilePath = _T("C:Sara emp.txt");
if (SaveFile.Open(strFilePath, CFile::modeCreate | CFile::modeNoTruncate | CFile::modeReadWrite), &fileException) {
[Code] ....
The above code not working correctly.
View 14 Replies
View Related
May 25, 2013
I have a function that essentially takes a screen shot and saves a pointer to it as a structure. I would like to use the same structure for bitmaps that I load from files.
Code:
typedef struct _BITMAPCAPTURE {
HBITMAP hbm;
LPDWORD pixels;
INT width;
INT height;
} BITMAPCAPTURE;
BOOL CaptureScreen(BITMAPCAPTURE* bmpCapture) {
[code].....
The handle to the bitmap, as well as the width and height are all easy enough to get but I'm unsure of how to get the pixels.
View 2 Replies
View Related
Oct 14, 2013
I have a text file name fruit.txt that contains the following information of fruit id, fruitName and fruitQuantity.
Code:
1:pear:30
2:apple:20
3:banana:24
4:orange:15
5:watermelon:35
If let's say I key in 2, it will search for the id=2 and delete the whole line and the id of banana which is orignially 3, will become 2 and orange which is orignally 4 will become 3 etc.
I researched on how it can be done and most suggested to put inside a vector and fout the line.
I know how to put the values in the vector but how should I go about searching for the id and if the id is found it will delete that line inside the file.
Code:
ofstream fout;
ifstream readFile("fruit.txt");
while (getline(readFile, line)) {
[Code]....
View 2 Replies
View Related
Feb 13, 2013
I am suppose to make a program that will output a line for a specific age group,but everytime I execute the exe file it gives me the desired line and also the last line included everytime.Where did I go wrong with it including the last line everytime?
#include <iostream>
using namespace std;
int main() {
double age;
cout<<"Enter your age:";
cin>>age;
if (0<age && age <6)
[Code] ......
View 1 Replies
View Related
Mar 10, 2013
Actually the below program is for Dispersal Algorithm called Rabin-IDA; this algorithm divided the data into N pieces and then recombine it from M pieces (such that M<N).
Thus, the below program needs command line arguments,which entering by Project properties/Debugging. this argument is file name, where the program performing spitted the file into N files, and then recombine it from M divided files, and put it on another file which should also passing its name as argument .
Now my question is, How can i make this program enter the file name by keyboard??(i mean enter the files name by user from screen not as command line arguments) ... In another word, How I can exchange ?
Code:
argc == 3
and
Code:
argc == 2
To enter file name ? i mean what i should do to in
Code:
rabin.split(argv[1])
To pass my file name by use keyboard not Project properties/Debugging?)
the below code is just the main function of program, and the whole of it in this link [URL] .... Information Dispersal Algorithms Rabin-IDA.
Code:
#include "include.h"
void __cdecl _tmain(int argc, TCHAR *argv[]) {
DWORD ini=GetTickCount();
try {
if( argc == 3 ) //recombine
[Code] ....
I know I should use getline() function but how exchange argv[] ?
View 1 Replies
View Related
Jan 23, 2013
this is my C# code
System.IO.Directory.SetCurrentDirectory
("C:/Users/fahime/Documents/Visual Studio 2010/WebSites/MyWebSite/UserFiles/ProblemAnswers/");
Process.Start("cmd.exe", @"/k ""C:Program Files (x86)Microsoft Visual Studio 10.0VCvcvarsall.bat"" x86");
[Code] .....
I want to compile my cpp code file with visual studio cmd
View 3 Replies
View Related
Feb 3, 2014
I was loaded a bmp file in my mfc window and stored rgb data in a file.My image size is 320x240.
Is possible to pick a single point (location) from that bmp image (Not the whole window)?
i like to plot a line graph using the pointed single line data using the stored file data?
here R is X Axis and G & B is Y Axis.
If i have 2D array of data means how can i plot the line graph?
View 4 Replies
View Related
Apr 21, 2014
I had created a global hook by SetWindowsHookEx with WH_CALLWNDPROC. It is used to create a new toolbar button in specific window in the specific (3rd party) program (named HOOKEE.exe for example), and it works perfectly fine most of the time. Normally HOOKEE.exe is launched by double clicking the shortcut icon on desktop. But this program could be also launched in another way (provided by the provider of HOOKEE.exe), with this new way, HOOKEE.exe is by conhost.exe (on Windows 7), and then I could see (via ProcessMonitor) my hook is loaded by conhost.exe, but not the process HOOKEE.exe. In my understanding global hook would be loaded by whatever process, I have no idea on the exception, and what conhost.exe does to the HOOKEE.exe.
View 13 Replies
View Related
Dec 8, 2013
How to get this thing to work. All i need to do is ask user to input a name and then it brings out the line from the .txt file containing the information.
For example in my case I'm doing a member search function I'm required to ask user to input the name of the customer and then print out all the details (which consumes 1 text line in the .txt file)
Here is the code, This is the write to text file method (100% working)
Code:
cout << "Customer Name: ";
cin >> name;
// ...
ofstream myfile("customer.txt", ios::app);
[Code] .....
View 3 Replies
View Related
May 21, 2014
Alright i have my program and it loads the vector fine and even puts the vector into a txt file but when it comes to lloading it again im not sure if it works or not
#include <iostream>
#include <string>
#include <fstream>
[Code]....
View 2 Replies
View Related
Sep 10, 2014
The program is supposed to read in a text file, load it into an array and assign a character to each number in the array (so for this I'm thinking I'll be creating 2 arrays, an int array with the numbers read in from the file, and a char array with the characters assigned to the numbers). It will then print these two arrays. It's then supposed to go through the initial int array and search for any numbers whose values differ from their neighboring values by more than one, if such a value is found, it's supposed to give the number the value of the average of it's neighboring values. It's supposed to make all these corrections and then assign characters to these corrected numbers and print out both arrays.
How to load the array from the file. My textbook seems to do a good job of covering arrays and files, but it doesn't really bring them together and talk about building arrays from files. Here is what the file looks like, the first number is the size of the array.
10
7 6 9 4 5 4 3 2 1 0
6 5 5 5 6 5 4 3 2 1
6 5 6 6 7 6 8 4 3 2
1 5 6 7 7 7 6 5 4 3
5 5 6 7 6 7 7 6 5 9
5 6 7 6 5 6 6 5 4 3
5 6 7 9 5 5 6 5 4 3
5 5 6 7 6 6 7 6 5 4
5 9 5 6 7 6 5 0 3 2
5 5 5 5 6 5 4 3 2 7
And here is the code I have so far:
#include <iostream>
#include <fstream>
using namespace std;
[Code]....
When I attempt to compile this (I'm working on a Linux system), I'm getting several errors:
prog1.cpp: In function ?int main()?:
prog1.cpp:37: error: expected unqualified-id before ?[? token
prog1.cpp:39: error: ?numArray? was not declared in this scope
prog1.cpp:39: error: expected primary-expression before ?]? token
View 14 Replies
View Related
Mar 29, 2013
What is the most efficient (fastest) way to load data from a file on HDD to RAM? (which would allow to only load a limited section of that file - eg. load only half of the file etc.)
View 3 Replies
View Related
Apr 21, 2015
I am trying to copy the stats from the save file "lol.txt" to main. I posted what the contents of the file below, but for some reason the I get for output jiberish and I cannot seem to figure out why.
#define _CRT_SECURE_NO_WARNINGS
#define MAX_NAME 31
#include <stdio.h>
int main(void){
char sName[MAX_NAME];
[Code] .....
View 5 Replies
View Related
Sep 12, 2013
I would like to validate one of my approach.
I am creating a map like
std::map<unsigned int, double> key_value_pair;
I insert the value like as follows
1 25.0
0 30.0
5 90.0
2 22.0
Then i would like to read the value like as follows
double value = key_value_pair[0];
I am able to compile & there is no error.
question is does this will give 30.0 always.?
I am using VS2005.
View 7 Replies
View Related
Jul 19, 2013
I'm having troubles with loading my text file into my array.
Code:
int main(int argc,char* argv[]) {
if(argc!=3) {
printf("
Insufficient arguments
[code]...
I'm also suppose to return the size of the input at the end.
View 3 Replies
View Related
Jun 11, 2014
What is the best / most efficient way to load polymorphic data from a file? I thought you could have an enumeration and for each item to load from a file you could have an integer at the start specifying the type of data, but I think there must be a better way I'm just not sure what.
Example of what I mean:
//The syntax isn't really that important for explanation
class base;
class a: base, b: base;
enum polymorphicType {
A,
B
};
and in the loading code you would have (this is the bit I think could be improved):
polymorphicType t;
File >> t;
if(t == A) {
newObject = new A;
} else if(t == B) {
newObject = new B;
}
I think there is probably a more efficient/better way of doing this I am just unaware of it.
View 4 Replies
View Related
Jan 29, 2013
Why my code is not working?
Interface
class Person{
private:
char name[80];
short age;
public:
void get_data();
[Code] .....
This is a simple example from and old Lafore C++ book, with a few tweaks by me. The point is simple. Save object person to a *.dat file, exit the program, then start up program again, open up *.dat file, and load contents.
The first problem is the compiler is printing a bunch of Asian characters to the file (is this normal?)
The second problem is, it's not loading the object as it should, giving me a bunch of gibberish.
View 9 Replies
View Related
May 9, 2014
#include <cstdlib>
#include <stdio.h>
#include <string>
[Code]....
I'm trying to load a file input stream to load all the character content into a variable (say from a .java file for example), but for some reason whenever I type in the name of the file I want to stream I get the report: RUN FAILED (exit value 1, total time 2s)
View 7 Replies
View Related
May 17, 2014
I'm trying to load a file that look like this:
IP:123.123.123.123
Port:12345
I can't figure out how to load multiple lines. I tried using , but I can't get it to work. Is there a better way of doing it than I am right now? This is my code.
char message[100];
int messageCount = 0;
for(unsigned int i = 0; i < file.size(); ++i) {
message[i] = file[i];
[Code] ....
View 1 Replies
View Related
Apr 28, 2014
Heres what I am suppose to do, So it doesnt seem hard to understand my messy code!
1. Gotta load the file "FactoryData.txt"
2. Load all values in my 2D array (array[5][3])
3. Print out the array to ensure that the copying went by well.
Heres my problem:
1. The for loops is REALLY off in my eyes. From my knowledge (correct me if im wrong), its suppose to be for(r=0;r<5;r++) not <=. BUT somehow im getting the results I want (in terms of formatting). HERE IS MY OUTPUT
Quote
300 450 500 510
510 600 750 627
627 100 420 530
530 621 730 200
200 50 58 100
100 83 4 5
Press Enter to return to Quincy...
View 8 Replies
View Related
Mar 18, 2015
I am doing a project in C++ - a simple data base (with "one table"). I want to build that data base using a LIFO or FIFO list, but this doesn't matter here
The only problem I have is that the structure of the data base is not "locked" in the code of the program, but when the program starts, it is "loaded / implemented" from a "configuration file" called "data.txt".
So the user, before she or he runs my program opens the file "data.txt" and writes the structure of the data base that se/he wants to create. This means that one time my program can be used to create a data base of students with fields such as "name / surname / gender / age / idnumber / university" but the next time it can be used for a data base of CD's with fields like - "author / release date / no. of tracks / etc.".
How to do that "loading" of a structure of a data base from a file, when the user runs my data-base creator (my C++ program).
View 1 Replies
View Related
May 25, 2012
I want to display a bmp file of resolution 600*420 (using c compiler like code block ) by manual loading. I tried to display the image by loading the pixel value. but this method has a limitation that it take up pixel value of image upto 64kb size.
So now i am trying to load it manually. What are the steps that i has to follow, what are the header files that i has to use ?
My system specification are windows xp professional , intel pentium 4 cpu. I don't know where to start ,does this method has any limitaton ,...etc ........
View 2 Replies
View Related
Mar 18, 2015
I am doing a project in C++ - a simple data base (with "one table").
I want to build that data base using a LIFO or FIFO list, but this doesn't matter here . The only problem I have is that the structure of the data base is not "locked" in the code of the program, but when the program starts, it is "loaded / implemented" from a "configuration file" called "data.txt".
So the user, before she or he runs my program opens the file "data.txt" and writes the structure of the data base that se/he wants to create. This means that one time my program can be used to create a data base of students with fields such as "name / surname / gender / age / idnumber / university" but the next time it can be used for a data base of CD's with fields like - "author / release date / no. of tracks / etc.".
How to do that "loading" of a structure of a data base from a file, when the user runs my data-base creator (my C++ program).
View 2 Replies
View Related
Aug 17, 2014
I am trying to read a file line by line and then do something with the informations, so my method looks like this:
Code:
void open_file(char *link) {
FILE *file = fopen(link, "r");
if (file == NULL) {
fprintf(stderr, "Could not open file.
");
exit(EXIT_FAILURE);
[Code] ....
1) The first complain of valgrind is at the line where I use fgets and its telling me (invalid write of size x), but I have allocated my line to 56000 and the read line is shorter, why is there a write size error then :S?
2) at the line where I realloc where I try to shrink the space he's telling me: Address .... is 0 bytes inside a block of size 56000, But I know i need only this space so why is there a write over space error :S??
View 9 Replies
View Related