Yesterday my code was capable of opening a file "larger.dat" and today I get this message when I am debugging:
std::string::c_str (this=0xffbffaf0)
at /home/maciej/src/opencsw/pkg/gcc4/trunk/work/solaris10-sparc/build-isa-sparcv8plus/objdir/sparc-sun-solaris2.10/libstdc++-v3/include/bits/basic_string.h:1820
1820 /home/maciej/src/opencsw/pkg/gcc4/trunk/work/solaris10-sparc/build-isa-sparcv8plus/objdir/sparc-sun-solaris2.10/libstdc++-v3/include/bits/basic_string.h: No such file or directory.
who is majiej? I'm not sure why it is not searching for the file in my own directory.
class NumList{
public:
static const size_t CAPACITY = 100;
// Default constructor
NumList();
// Precondition: none
// Postcondition: num is placed at the end of the list,
// if there is sufficient Capacity
void insert(int num);
size_t size()const {return used;}
//Precondition: istream is a stream that has already been connected to
// a successfully opened file
// Postcondition: integers from the file are loaded into the object
void load_from_file(std::ifstream& ins);
// Preconditon: ostream is connected to a successfully open file
// Postconditon numbers in the object are written to the file
void save_to_file(std::ofstream& outs);
void b_sort();
int get_item(size_t index)const;
void see_all()const;
private:
int data[CAPACITY];
size_t used;
};
#endif
#include "numlist.h"
#include <fstream>
#include <cstdlib>
using namespace std;
// Constructor
NumList::NumList(){
used = 0;
}
void NumList::insert(int num){
if(used <CAPACITY){
data[used] = num;
used++;
}
else{
cout<<"Error. List capacity has been reached.\n";
}
}
void NumList::load_from_file(std::ifstream& ins){
int tmp;
ins.open("filename.dat");
while (ins >> tmp)
insert (tmp);
}
void NumList::save_to_file(std::ofstream& outs){
int tmp;
outs.open("fileout.dat");
void NumList::save_to_file(std::ofstream& outs){
int tmp;
outs.open("fileout.dat");
while (outs << tmp)
insert(tmp);
}
void NumList::b_sort(){
bool done = false;
int j;
int tmp;
while(!done){
done = !true;
for(j=used-1; j>= 0; --j){
if(data[j] < data[j-1]){// changed direction of < to >
done = false;
tmp = data[j];
data[j] = data[j-1];
data[j=1] = tmp; //changed j=1 to j-1
}
}
}
}
#include<iostream>
#include<fstream>
#include "numlist.h"
using namespace std;
int main()
{
NumList num1;
int tmp;
ifstream ifs;
string filename;
cout<<"Please enter the name of your number file.\n";
cin>>filename;
ifs.open(filename.c_str());
if(ifs.fail()){
cout<<"Input file failed to open.\n";
return -1;
}
num1.load_from_file(ifs);
ifs.close();
num1.see_all();
cout<<"Please enter three numbers to add to the list.\n";
cin>>tmp;
num1.insert(tmp); //1
cin>>tmp;
num1.insert(tmp); //2
cin>>tmp;
num1.insert(tmp); //3
num1.b_sort();
num1.see_all();
char c= '.';
int some_int;
some_int = filename.find(c);
filename.insert(some_int, "sorted");
num1.load_from_file(ifs);
ifs.close();
num1.see_all();
cout<<"Please enter three numbers to add to the list.\n";
cin>>tmp;
num1.insert(tmp); //1
cin>>tmp;
num1.insert(tmp); //2
cin>>tmp;
num1.insert(tmp); //3
num1.b_sort();
num1.see_all();
char c= '.';
int some_int;
some_int = filename.find(c);
filename.insert(some_int, "sorted"); //check this pls
The message is innocuous. It means the debugger can't find the sources referenced by the debugging symbols in the library. maciej is the user name in their computer of the person who built the library.