Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 189061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:08:27+00:00 2026-05-11T16:08:27+00:00

This is driving me nuts. I have been at it for over 2 hours

  • 0

This is driving me nuts. I have been at it for over 2 hours trying to figure this out…

Here is my problem. I am working on a fairly large program that works with Bayesian networks. Here is the main function:

using namespace std;

int main()
{  
    DSL_network net;
    initializeNetwork(net); 
    setEvidence(net);
    net.SetDefaultBNAlgorithm(7);
    net.SetNumberOfSamples(80000);
    cout << "Samples:\t" << net.GetNumberOfSamples() << endl;
    updateEvidence(net);
    //net.WriteFile("test.dsl");
    return(DSL_OKAY);
}

This all works fine. The problem comes when I want to print out a string:

using namespace std;

int main()
{  
    //simple string creation
    string a = "test";
    //should print out "test"
    cout << a << endl;
    DSL_network net;
    initializeNetwork(net); 
    setEvidence(net);
    net.SetDefaultBNAlgorithm(7);
    net.SetNumberOfSamples(80000);
    cout << "Samples:\t" << net.GetNumberOfSamples() << endl;
    updateEvidence(net);
    //net.WriteFile("test.dsl");
    return(DSL_OKAY);
}

Here is the output (just from printing the string a…):

   ▀ÇΦy♠≈6 ♦

What could be going on?

UPDATE:

int main()
    {  
        //simple string creation
        string a = "test";
        //should print out "test"
        cout << a << endl;
        return(DSL_OKAY);
    }

still prints

▀ÇΦy♠≈6 ♦

BIG UPDATE:
Here is the recent. I created a brand new project and pasted the code that Neil Butterworth posted (thanks btw). I ran the code and it printed correctly. Then I added the two .lib files to the Linker in the new project (smile.lib for the SMILE library, and wsock32.lib for socket use.)

I tried the code again, and it printed the first “test” correctly, then it printed the giberish. It is a problem with one of the .libs I am linking together. I tried each on their own to see if they are just clashing, and it seems that the smile.lib library is causing the problem. I will need to go into their documentation and figure out why.

Any ideas?

Thanks all for the help

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T16:08:27+00:00Added an answer on May 11, 2026 at 4:08 pm

    That’s bizarre. I always like to break a problem down to it’s minimal case. What does the following program do when you run it?

    using namespace std;
    int main() {  
        string a = "test";
        cout << a << endl;
        return 0;
    }
    

    If that works, then there’s something else wrong and you need to add in one line at a time until it fails. Then examine that line very carefully (“I’m hunting wabbits”).

    Based on your edit, it may be a different string class being used. Try this:

    int main() {  
        std::string a = "test";
        std::cout << a << std::endl;
        return 0;
    }
    

    Update:

    Since it works in a new project and not the current one, check the following.

    • Make sure you’re linking with the standard C++ runtimes.
    • make sure you don’t #define string as something else (and the includes a -Dstring=somethingelse command line option to the compiler).
    • check the behavior using std::string, not just string.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This has been driving me nuts for a week now. I have a class
This has been driving me nuts all day. I have a weird bug that
This has been driving me nuts all day. I've seen this problem crop up
This is driving me nuts. I have a working text based application. It has
This one has been driving me nuts. I have a div that has it's
This error has been driving me nuts. We have a server running Apache and
This has been driving me absolutely nuts. I have a substitute function like this:
I have been trying to do this for nearly 3 days now. Its driving
So this has just been driving me nuts! I have looked through tons of
This problem has been driving me nuts all day and there has to be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.