Hello, Is there away(method) in C/C++ programming that make the software think that someone pressed the OK button, similar to sendkeys in VBS (WshShell.SendKeys ("{Enter}")) Thank you, Sam
Hello, I wrote a C program that loop inside a folder which has about 200 text files. Each file has almost 60000 lines. I created 2D array [60000][200] to store files in it. No compilation problem at all, but when I try to run it I get this error (fault core dump). Yes I did use malloc() This is my code: /////////////// #include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> #define WIDTH 200 // total number of files #define HEIGHT 60000 // total number of lines for each file int main () { double **array1; array1 [HEIGHT][WIDTH]; int w ,h; int fnum = 1; char filename [64]; double *data; FILE * fpr; FILE * fpw; // reading files data to array1 array1 = (double **) malloc(HEIGHT*sizeof(double)); for (w=0;w<WIDTH;w++) { sprintf(filename, "C:/User/data%d.txt", fnum); ; fpr = fopen(filename, "r"); for (h=0;h<HEIGHT;h++) { array1[h] = (double *) malloc(WIDTH*sizeof(double)); fscanf(fpr, "%lf", &array1 [h][w]); fclose(fpr); } fnum ++; } return 0; } //////////////// Thank you, Sam
Hello, You are reading on a closed file, try moving the fclose to the other side of the curly bracket. HTH, Jon
fpr = fopen(filename, "r");
for (h=0;h<HEIGHT;h++) { array1[h] = (double *) malloc(WIDTH*sizeof(double));
fscanf(fpr, "%lf", &array1 [h][w]);
fclose(fpr);
}
Thank you Jonathan for your quick response. well, i did move it. still same problem. it has something to do with memory -------------------------------------------- On Mon, 9/30/13, Jonathan WRIGHT <wright@esrf.fr> wrote: Subject: Re: [C++-sig] fault core dump error To: cplusplus-sig@python.org Date: Monday, September 30, 2013, 9:49 AM Hello, You are reading on a closed file, try moving the fclose to the other side of the curly bracket. HTH, Jon
fpr = fopen(filename, "r"); for (h=0;h<HEIGHT;h++) { array1[h] = (double *) malloc(WIDTH*sizeof(double));
fscanf(fpr, "%lf", &array1 [h][w]);
fclose(fpr);
}
_______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@python.org https://mail.python.org/mailman/listinfo/cplusplus-sig
I think you may be sending to a mailing list that isn't really appropriate for your questions; this list concerns integrating C++ with Python (often focusing on Boost.Python), not general C/C++ programming. Good luck! Jim On 09/30/2013 11:40 AM, sam wrote:
Hello, I wrote a C program that loop inside a folder which has about 200 text files. Each file has almost 60000 lines. I created 2D array [60000][200] to store files in it. No compilation problem at all, but when I try to run it I get this error (fault core dump). Yes I did use malloc() This is my code:
///////////////
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h>
#define WIDTH 200 // total number of files #define HEIGHT 60000 // total number of lines for each file
int main () {
double **array1; array1 [HEIGHT][WIDTH];
int w ,h; int fnum = 1; char filename [64]; double *data; FILE * fpr; FILE * fpw;
// reading files data to array1
array1 = (double **) malloc(HEIGHT*sizeof(double));
for (w=0;w<WIDTH;w++) {
sprintf(filename, "C:/User/data%d.txt", fnum); ;
fpr = fopen(filename, "r");
for (h=0;h<HEIGHT;h++) { array1[h] = (double *) malloc(WIDTH*sizeof(double));
fscanf(fpr, "%lf", &array1 [h][w]);
fclose(fpr);
}
fnum ++; }
return 0; }
////////////////
Thank you, Sam
_______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@python.org https://mail.python.org/mailman/listinfo/cplusplus-sig
Sam, this looks really awful: double **array1; array1 [HEIGHT][WIDTH]; do you mean: double **array1; //array1 [HEIGHT][WIDTH]; But this might not be your probablem. You say " folder which has about 200 text files", but your code is treating this as "exactly 200 text files", you need to do something there. Then again please recall the reminder of Jim Bosch and maybe post this problem on a different list, maybe stackexchange? -Holger On Mon, Sep 30, 2013 at 5:40 PM, sam <asu_mcs@yahoo.com> wrote:
Hello, I wrote a C program that loop inside a folder which has about 200 text files. Each file has almost 60000 lines. I created 2D array [60000][200] to store files in it. No compilation problem at all, but when I try to run it I get this error (fault core dump). Yes I did use malloc() This is my code:
///////////////
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h>
#define WIDTH 200 // total number of files #define HEIGHT 60000 // total number of lines for each file
int main () {
double **array1; array1 [HEIGHT][WIDTH];
int w ,h; int fnum = 1; char filename [64]; double *data; FILE * fpr; FILE * fpw;
// reading files data to array1
array1 = (double **) malloc(HEIGHT*sizeof(double));
for (w=0;w<WIDTH;w++) {
sprintf(filename, "C:/User/data%d.txt", fnum); ;
fpr = fopen(filename, "r");
for (h=0;h<HEIGHT;h++) { array1[h] = (double *) malloc(WIDTH*sizeof(double));
fscanf(fpr, "%lf", &array1 [h][w]);
fclose(fpr);
}
fnum ++; }
return 0; }
////////////////
Thank you, Sam
_______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@python.org https://mail.python.org/mailman/listinfo/cplusplus-sig
participants (4)
-
Holger Brandsmeier -
Jim Bosch -
Jonathan WRIGHT -
sam