Member Avatar for davidrgarber

In the code below, when I try to output out_phrase_char, I get a message that says "The Debugger has exited due to signal 10 (SIGBUS).The Debugger has exited due to signal 10 (SIGBUS)." Please help me as soon as possible. This is due at 11:59pm.

// classes example
#include <iostream>
#include <cstdlib>
using namespace std;

class MyClass
{

public:
    int *getNiCount(const char *phrase_char, const wchar_t *phrase_wchar) {
        int index = 0;
        int *num_occurences = new int[2];

        while(phrase_char[index] != '\0') {
            if(phrase_char[index] == 'N' && phrase_char[index+1] == 'i') {
                num_occurences[0] = num_occurences[0] + 1;
            }
            index++;
        }
        index = 0;
        while(phrase_wchar[index] != '\0') {
            if(phrase_wchar[index] == 'N' && phrase_wchar[index+1] == 'i') {
                num_occurences[1] = num_occurences[1] + 1;
            }
            index++;
        }

        return num_occurences;
    }
    char replaceNiWithNI(const char *phrase_char, const wchar_t *phrase_wchar) {
        size_t temp;
        char *out_phrase_char = (char*)phrase_char;
        char *out_phrase_wchar;
        temp = wcstombs(out_phrase_wchar, phrase_wchar, 14);
        char *output_phrases = new char[2];
        int index = 0;

        while(phrase_char[index] != '\0') {
            if(phrase_char[index] == 'N' && phrase_char[index+1] == 'i') {
                out_phrase_char[index+1] = 'I';
            }
            index++;
        }
        index = 0;
        while(phrase_wchar[index] != '\0') {
            if(phrase_wchar[index] == 'N' && phrase_wchar[index+1] == 'i') {
                out_phrase_wchar[index+1] = 'I';
            }
            index++;
        }
//output_phrases[0] = out_phrase_char;
//output_phrases[1] = out_phrase_wchar;
        return *out_phrase_char;
    }
};


int main ()
{
    MyClass phrase1;
    const char *szTestString1 = "Ni nI NI nI Ni";
    const wchar_t *szTestString2 = L"Ni nI NI nI Ni";

    int *num_occurences = phrase1.getNiCount(szTestString1,szTestString2);
    char out_phrase_char = phrase1.replaceNiWithNI(szTestString1,szTestString2);
    cout << out_phrase_char << endl;
    return 0;
}

Double posting is selfish. Show some respect for peoples' time and pick a forum and stick with it. You've already been helped there. Anyone on daniweb who helps you is likely going to give you the same advice.

http://www.codeguru.com/forum/showthread.php?p=2037720

Double posting is selfish. Show some respect for peoples' time and pick a forum and stick with it. You've already been helped there. Anyone on daniweb who helps you is likely going to give you the same advice.

http://www.codeguru.com/forum/showthread.php?p=2037720

Not really, if you're looking for an answer to a question as quickly as possible it makes perfect sense to ask around wherever you can.

Only thing I would say is disrespectful is not posting when you found the answer to your problem with what the answer is and a thank you to anybody who helped; Posting on another forum is fine

You're in the vast minority. Cross posting is considered extremely rude. I feel confident that pretty close to 100% of the regular helpers here and on any other forum would agree. Sure "it makes perfect sense" for the original poster. Selfish behavior usually does make perfect sense if all you care about is getting the answer "by 11:59 pm" (that's another red flag. This isn't a "help me" thread, this is a "gimme teh codez" thread). and never plan on showing up again. It doesn't cost the original poster anything at all to have me waste my time crafting a response that will never be read to his question because it's already been answered over at codeguru and I had no idea that it was. It DOES waste the helpers' time though. The ratio of helpers to askers is already about 1:100. Threads like these just decrease that ratio.


>> Posting on another forum is fine

Indeed it is. What's not fine, again, is posting the exact same question at the same time on multiple forums and not telling all the forums about your other posts.


See this link.
http://www.catb.org/~esr/faqs/smart-questions.html

Choose your forum carefully

Be sensitive in choosing where you ask your question. You are likely to be ignored, or written off as a loser, if you:

post your question to a forum where it's off topic

post a very elementary question to a forum where advanced technical questions are expected, or vice-versa

cross-post to too many different newsgroups

post a personal e-mail to somebody who is neither an acquaintance of yours nor personally responsible for solving your problem

Hackers blow off questions that are inappropriately targeted in order to try to protect their communications channels from being drowned in irrelevance. You don't want this to happen to you.

>> Posting on another forum is fine

Indeed it is. What's not fine, again, is posting the exact same question at the same time on multiple forums and not telling all the forums about your other posts.


See this link.
http://www.catb.org/~esr/faqs/smart-questions.html

Only thing I would say is disrespectful is not posting when you found the answer to your problem with what the answer is and a thank you to anybody who helped

I already mentioned that ;) but no, it's all opinion based really. The majority of people I speak to are fine with asking things in multiple places just because you need a quick answer while less people are fine with just expecting the answers to problems. It all depends on the situation ^ ^

You're talking to the question ASKERS. Ask the people you speak to if it would bother them if it would bother them if they HELPED someone who cross-posted without notifying both forums ahead of time that he was doing it. If they wouldn't mind, they're different from the ones I speak to. Everyone who helps people regularly hates it.


>> because you need a quick answer

These forums aren't about "quick answers". That's "rent-a-coder". We give nudges in the right direction and if it was due at 11:59 p.m., the guy should have posted earlier. And not surprisingly the guy indeed did NOT give a thank you to the guy who helped him at codeguru or even a response so he's clearly in the "just expecting the answers to problems" category. 11:59 p.m. came and went and he was gone.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.