C++ :: Segfault At Declaration Of 2D Array
Jan 19, 2014
I have a little program that does some statistical processing on text files. The program has thrown a segmentation fault with an input file that is larger that I have used before. I didn't write this tool, so I went searching for the problem. Data from the input file is dumped into a 2D array and the program fails at the declaration of that array.
Code : double A[cont][Nr_col_split];
The vales for cont and Nr_col_split and determined from the input file and in this case, cont=807 and Nr_col_split=350. I assume that these values are just too large and not enough memory can be allocated, or something like that. Do I need to use reserve or similar to set aside enough memory? I will have input files that are quite a bit bigger than this one, so perhaps there needs to be a different solution for storing the input file data.
View 10 Replies
Nov 2, 2013
I wrote a program to detect if a graph is tree or not. Initially it was using static memory. Later I changed it to use memory dynamically using malloc().My problem is that, my program it works great for case when graph is not tree but fails if it is.
Code:
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
int main()
}
[code]....
View 2 Replies
View Related
May 22, 2013
I am trying to send a packet across a client/server communication. I am getting a seg fault (while running the program(It compiles fine)) when I try to read the neighbor file, You should be able to see this below the comment /***** Read neighbor file***/ :
Code:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
}
[code]....
View 2 Replies
View Related
Mar 18, 2014
The program I'm working on is a very basic relational database. I've isolated my problem for simplicity. I get a segfault right here when I try to access db->relationCount. I tried printing db->relationCount from within loadDB and that worked,
[code]
loadDB(db, configFile);
printf("%d",db->relationCount);
fflush(stdout);
View 5 Replies
View Related
Jan 7, 2013
I would like to know the difference between the following two forms of array declaration:
(1)double myArray[3] = {1.0, 2.0, 3.0};
(2)array<double,3> myArray = {1.0, 2.0, 3.0};
If I say the second one allows to use different functions like .begin(), am I right? Is there any other difference between these two declaration?
View 6 Replies
View Related
Jan 24, 2014
I want to understand the ways in which arrays can be declared and used. What each of the following do or what's the difference between them and what would be the length of each:-
1 - char ary1[50];
2 - char ary2[50] = {'H','e','l','l','o'};
3 - char ary3[50] = {'H','e','l','l','o','