Hi guys i have written the following code. when completed, it is supposed to read data from a Gmsh mesh file. but i keep receiving a SIGBRT signal right before the while loop in the function "find_preliminary_info_from_file". i would be very thankful if you helped me out
#include <iostream>
#include <fstream>
#include <math.h>
#include <string>
#include "auxiliary_functions.h"
usingnamespace std;
int main () {
constint max_num_char_in_line = 512;
std::cout << "This commandline tool has been designed to solve the 2D pure advection problem presented as the term project to the Finite Element Method course by Dr. Manzari. The code has been written by Bamdad Hosseini 85110129. The code has been written using apples Xcode 3.1 and compiled under gcc 4.2 and LLVM gcc 4.2 compilers. The problem is solved on a unit square using linear triangular elements generated by Gmsh 2.4.2. \n please push the enter if you wish to run this program." << endl;
std::cout << endl;
string mesh_file_address;
mesh_file_address = "/Users/bamdadhosseini/Desktop/mesh/FEMmesh.txt";
int number_of_nd_ele[2];
int nd_ele_line[2];
find_preliminary_info_from_file(mesh_file_address, max_num_char_in_line, nd_ele_line, number_of_nd_ele);
}
#include <iostream>
#include <fstream>
#include <math.h>
#include <string>
#include "auxiliary_functions.h"
#include "math_functions.h"
#include "data_structure.h"
usingnamespace std;
int main () {
constint max_num_char_in_line = 512;
std::cout << "This commandline tool has been designed to solve the 2D pure advection problem presented as the term project to the Finite Element Method course by Dr. Manzari. The code has been written by Bamdad Hosseini 85110129. The code has been written using apples Xcode 3.1 and compiled under gcc 4.2 and LLVM gcc 4.2 compilers. The problem is solved on a unit square using linear triangular elements generated by Gmsh 2.4.2. \n please push the enter if you wish to run this program." << endl;
//std::cin.get();
std::cout << endl;
//std::cout << "please enter the address of the Gmsh mesh file:" << endl;
string mesh_file_address;
//std::cin >> mesh_file_address;
//std::cin.get();
mesh_file_address = "/Users/bamdadhosseini/Desktop/mesh/FEMmesh.txt";
int number_of_nd_ele[2];
node *global_nodes;
element *global_elements;
int nd_ele_line[2];
//find_preliminary_info_from_file(mesh_file_address, max_num_char_in_line, nd_ele_line, number_of_nd_ele);
float x;
ifstream myfile;
myfile.open("/Users/bamdadhosseini/Desktop/mesh/FEMmesh.txt");
while (!myfile.eof()) {
myfile >> x;
std::cout << x << endl;
}
myfile.close();
}
but no matter what i do the code reads 0 instead of anything! what is wrong here? i also used getline and a string but the string variable doesnt read anything. what am i doing wrong?
that is ture, but the problem is that i changed the .txt to include a number of integers and floats, no text, and still i could not get anything. i tried defining x as a character and i managed to read the files character by character. i still dont understand what im doing wrong. i have checked like 20 sample codes for this purpose and i still cant find the problem. and i have a feeling its one of those bugs that makes you hate your self when you find it :|