• Hey, guest user. Hope you're enjoying NeoGAF! Have you considered registering for an account? Come join us and add your take to the daily discourse.

C++ Help?

Status
Not open for further replies.
ok so after a not-so-good night sleep. i kinda get it. but i need help starting.

can you tell me if i am on the right track. or just completely off.

Well not completely off, but I guess I have to take a step further back (as I don't think this code will even compile).

Couple questions:

1) When is the assignment due?

2) What was your intent with this?

Code:
        spy(*spy){
                std::stringstream *spy;
                       
       
               
        }

3) Do you know how to use overloaded operators?

4) Do you know how to use templates?

(BTW, questions 3 and 4 are hints as to what is needed for the solution)
 

Complex Shadow

Cudi Lame™
1) next wed. Got it last week wed but was working on a perl assignment the whole week.(Which I have to kinda redo)
2) no clue. I guess I was trying to take the pointer of the string and pass it through a function. Dunno why.
3) I've heard of operator overloading but have had no practice.
4) no clue.
 

Lathentar

Looking for Pants
Well not completely off, but I guess I have to take a step further back (as I don't think this code will even compile).

Couple questions:

1) When is the assignment due?

2) What was your intent with this?

Code:
        spy(*spy){
                std::stringstream *spy;
                       
       
               
        }

3) Do you know how to use overloaded operators?

4) Do you know how to use templates?

(BTW, questions 3 and 4 are hints as to what is needed for the solution)
You don't need to know how to do 4 (I know its the correct solution, but in his case he just needs to get the provided main working)
 
Plus we (my class) hasn't been taught overloading yet. Well in depth anyways.

You basically have to know overloading to solve the problem. But he's right about templates, it's not required. So ignore #4 there.

Anyway, in short, overloading lets you define a function that gets called whenever you use an operator in a statement. In this case, the operator is <<. So basically

spy << "foo";

will look for a function called this:

SpyOutput& operator<<(const char* str);

and similarly,

spy << 12.4;

will look for a function called this:

SpyOutput& operator<<(double d);


So here's a basic skeleton of a class you might use:

Code:
class SpyOutput
{
public:
   //YOUR CODE HERE

   SpyOutput& operator<<(const char* str)
   {
      //YOUR CODE HERE
      return *this;
   }

   SpyOutput& operator<<(double d)
   {
      //YOUR CODE HERE
      return *this;
   }

   int getcount()
   {
      //YOUR CODE HERE
   }

   int getchecksum()
   {
      //YOUR CODE HERE
   }
private:

   //YOUR CODE HERE
};

Everywhere there's a //YOUR CODE HERE comment, there's some code you need to write yourself.

If it helps you to understand what's going on, try to use your main function with this class and see what kind of compiler errors you get. It's hard to say more without totally giving away the solution, so spend a few hours with this and see what you can figure out on your own.

If you're using Visual Studio, then it should be easy for you to get this under a debugger and maybe step through the code and see how things are working. That's one of the best ways to learn IMO.
 

Complex Shadow

Cudi Lame™
You basically have to know overloading to solve the problem. But he's right about templates, it's not required. So ignore #4 there.

If it helps you to understand what's going on, try to use your main function with this class and see what kind of compiler errors you get. It's hard to say more without totally giving away the solution, so spend a few hours with this and see what you can figure out on your own.

If you're using Visual Studio, then it should be easy for you to get this under a debugger and maybe step through the code and see how things are working. That's one of the best ways to learn IMO.
i will....in the morning (got no sleep last night). but yea i am determined to do/learn this.

so as i was working on first operator and logically what i want to do is take the string and store it in a buffer then use string stream to convert whats in the buffer to ASCII. right?

Code:
   SpyOutput& operator<<(const char* out)
   {
      
		char membuff[buff];
		ostrstream out(membuff, buff);

	  std::stringstream s;
			  s<<out
                          s.lenth();
		return *this;
   }
 
i will....in the morning (got no sleep last night). but yea i am determined to do/learn this.

so as i was working on first operator and logically what i want to do is take the string and store it in a buffer then use string stream to convert whats in the buffer to ASCII. right?

Code:
   SpyOutput& operator<<(const char* out)
   {
      
		char membuff[buff];
		ostrstream out(membuff, buff);

	  std::stringstream s;
			  s<<out
                          s.lenth();
		return *this;
   }

The first two lines aren't necessary. In fact, for this version of the operator (the one whose argument is already a string), you don't even need anything special at all. Recall the problem requirements:

1) Keep a running tally of the total number of characters written
2) Keep a running tally of the arithmetic sum of all characters. (do you know what this means btw?)

You don't even need stringstream for any of this. The entire point of stringstream for this problem is to convert numbers to strings so that you can do steps 1 and 2 above on the string. In this case, the argument is already a string, so the first part of the probelm is solved. Just do steps 1 and 2.

For the other version of the function, where the argument is a double, you have to use stringstream first to convert the number to a string, and then do steps 1 and 2 on the result.
 

Blizzard

Banned
If you mean until the SUM exceeds 25,000, you'll need to use a while loop. Remember, for loops are for when you know beforehand how many times the loop will be run. Otherwise, use the more flexible while loop, which will continue to do something until a specific condition is reached.
Late response here, but why do you say this? For loops continue until a specific condition is reached, just like while loops. For loops are more flexible since you can also do an assignment(s) and an update statement(s) inside the loop.
 

Feep

Banned
Late response here, but why do you say this? For loops continue until a specific condition is reached, just like while loops. For loops are more flexible since you can also do an assignment(s) and an update statement(s) inside the loop.
For-loops execute until a given condition is reached, but it's not necessarily easy for a beginner to think about them that way. They're technically the same thing (I believe you can skip the initialization and auto-increment sections). While loops can do anything a for loop can do; you can assign and update as you will inside the loop.
 

Blizzard

Banned
For-loops execute until a given condition is reached, but it's not necessarily easy for a beginner to think about them that way. They're technically the same thing (I believe you can skip the initialization and auto-increment sections). While loops can do anything a for loop can do; you can assign and update as you will inside the loop.
Yes, you can skip the initialization and auto-increment/decrement/whatever sections, but the main point I was meaning was that end condition isn't necessarily fixed.

As a simplification while loops are simpler to think about, for sure. :)
 

Godslay

Banned
For-loops execute until a given condition is reached, but it's not necessarily easy for a beginner to think about them that way. They're technically the same thing (I believe you can skip the initialization and auto-increment sections). While loops can do anything a for loop can do; you can assign and update as you will inside the loop.

I'm sure you know this but for beginners, For loops can be "unrolled" into while loops, and while loops can be "rolled" into for loops. For instance:

Code:
        //For loop
        for(int i = 0; i < 5; i++){
            System.out.println("Value of i: " + i);
        }
        
        //For loop "unrolled" into a while loop
        int j = 0;
        while(j < 5){
         System.out.println("Value of j: " + j);
         j++;
        }


These have the exact same output (it's Java though). In this case, initializing, and incrementing happen in the "body" of the for loop, in the while loop incrementing and initializing happen outside of the "body" of the while loop, hence the "unrolled" name.
 

jokkir

Member
I need some clarification.

When doing multi-dimensional arrays, can you change the value of the how large the array is after each instance?

I mean uhmm...

Code:
char array[0][3];

Let's say the 0 changes to array[1], can you change the 3 to some other length or is it not changeable?

Hopefully that made sense >__>
 

BlueMagic

Member
I need some clarification.

When doing multi-dimensional arrays, can you change the value of the how large the array is after each instance?

I mean uhmm...

Code:
char array[0][3];

Let's say the 0 changes to array[1], can you change the 3 to some other length or is it not changeable?

Hopefully that made sense >__>

You mean, while the program is running? If so, no. The program needs to know beforehand how much memory it will be allocating (since you are allocating statically), so there's no way of doing that with static memory. However, there's a way of allocating memory while the program is running, and it is called dynamic allocation. It offers some disadvantages such as being slow, and not entirely safe, but it has the obvious advantage of allowing to do what you asked. Read up on malloc() (if you are using C), or the new operator if you are using C++.
Notice that every time you use malloc or new, it is up to the programmer to free the memory that was previously allocated, using "free" for malloc and "delete" for "new"
 

tokkun

Member
Code:
char array[0][3];

What are you trying to do here? This code would try to declare an array of zero rows and three columns, and I'm guessing that is not your intention.

If you want to declare an array with variable row length with static allocation you can do it like this:

char *my_array[NUM_ROWS];
char row0[NUM_COLS_ROW0];
my_array[0] = row0;
char row1[NUM_COLS_ROW1];
my_array[1] = row1;
....
 

Complex Shadow

Cudi Lame™
The first two lines aren't necessary. In fact, for this version of the operator (the one whose argument is already a string), you don't even need anything special at all. Recall the problem requirements:

1) Keep a running tally of the total number of characters written
2) Keep a running tally of the arithmetic sum of all characters. (do you know what this means btw?)

You don't even need stringstream for any of this. The entire point of stringstream for this problem is to convert numbers to strings so that you can do steps 1 and 2 above on the string. In this case, the argument is already a string, so the first part of the probelm is solved. Just do steps 1 and 2.

For the other version of the function, where the argument is a double, you have to use stringstream first to convert the number to a string, and then do steps 1 and 2 on the result.
but that would mean that i would have to put all the charc in an array. then count whats in the array. and take the sum of all the ascii values (for the sum).

also i get an error for endl, VS says that there is no operator that handles endl.
 
but that would mean that i would have to put all the charc in an array. then count whats in the array. and take the sum of all the ascii values (for the sum).

also i get an error for endl, VS says that there is no operator that handles endl.

not really. you could concatenate all the inputs into one string, take the number of characters from the length of the string (minus endlines?), then iterate through the string (for .. until strlen) char by char totalling the ascii values (with or without endlines, whatever).

edit: derp, below is right, you don't need to keep any strings, just iterate over the argument and add to the sum & char count. but like he says spend some time learning about strings :) (c & c++ implement them differently too, so watch out)
 
but that would mean that i would have to put all the charc in an array. then count whats in the array. and take the sum of all the ascii values (for the sum).

also i get an error for endl, VS says that there is no operator that handles endl.

You dont have to do anything involving copying stuff into an array. A char* is already an array

If you have the function

Code:
Void foo(char* arg)
{
}

foo("abcde");

and you want to count the number of characters just use strlen(). And if you want to compute the sum, use a for loop and index 'arg' the same was as you would with an array

arrays and pointers are basically the same thing.


The only thing you need to keep track of between calls to the operator is:

1) Total number of characters
2) Sum of integral values of characters.


So there's no reason to do anything crazy like keeping one big long string in the class that you keep concatenating over and over. Just each time the operator is called, a) take the length and add it to your running sum, and b) compute the arithmetic sum of the input and add it to a separate running sum.


I mean no disrespect, but if you intend to pursue computer science as your major or some such, I would really advise some outside help or perhaps retaking an earlier class. Don't get me wrong, I don't mind helping you until the cows come home, but the problem IMO is that you missed some of the much more fundamental aspects of C / C++ programming that you should have learned in an earlier course.

Of course, there's a chance you only want to pass the course because it's required for some kind of engineering degree or something, in which case maybe you just want to skate through.
 

jokkir

Member
I need help again :\. I'm trying to code something to compare two sentences together. The conditions are that they can be either lower case or upper case but if there are any symbols used, they have to be the same.

My if statement to compare to get around the upper case/lower case problem looks like this:
Code:
if(str[j] == sentence[i] || tolower(str[j]) == tolower(sentence[i]) || toupper(str[j]) == toupper(sentence[i]))
					{
						printf("in to lower sentence[i] - %c\n", sentence[i]);
						printf("     in to lower str[i] - %c\n", str[j]);
						returnVal = 1;
					}

The problem I have is that the two symbols are not the same but I don't know what kind of if statement I should use to check for it.

The two sentences I'm comparing are:
"Non_sEQitur" and "Non-seqitur"

Thanks!
 

jokkir

Member
Why not just use tolower once on the indiviual characters, then compare them afterward? tolower doesn't affect non-alpha chars.

I tried to change it to this:

for(i = i; i < strlen(str) + p; i++)
{
if(isalnum(sentence) || isalnum(str[j]))
{
str[j] = tolower(str[j]);
sentence = tolower(sentence);
}

printf("i value - %d\n", i);
printf("j value - %d\n", j);

if(str[j] == sentence)
{
printf("in to lower sentence - %c\n", sentence);
printf(" in to lower str - %c\n", str[j]);
returnVal = 1;
}

j++;
}


It seems to be skipping the special character when doing the comparison for some reason. Anyone know why?
 

Complex Shadow

Cudi Lame™
I mean no disrespect, but if you intend to pursue computer science as your major or some such, I would really advise some outside help or perhaps retaking an earlier class. Don't get me wrong, I don't mind helping you until the cows come home, but the problem IMO is that you missed some of the much more fundamental aspects of C / C++ programming that you should have learned in an earlier course.

Of course, there's a chance you only want to pass the course because it's required for some kind of engineering degree or something, in which case maybe you just want to skate through.
won't lie to you. i have holes in my C++ knowledge. they're actually worse than holes. but i really need to pass this course. its my last C++ course ill ever take but its compulsory. and i just want this to end. honestly even i find it sad at this point.
 
won't lie to you. i have holes in my C++ knowledge. they're actually worse than holes. but i really need to pass this course. its my last C++ course ill ever take but its compulsory. and i just want this to end. honestly even i find it sad at this point.

Here's the class I wrote earlier, with another piece of the puzzle filled in and some pseudocode

Code:
class SpyOutput
{
public:
   SpyOutput(std::ostream& otherStream)
       : outputStream(otherStream)
       , arithmeticSum(0)
       , numChars(0)
   {
   }

   SpyOutput& operator<<(const char* str)
   {
      //count the number of letters in str and add it to numChars

      //add the numeric value of each character in str to arithmeticSum

      //write str to the underlying stream
      return *this;
   }

   SpyOutput& operator<<(double d)
   {
      //convert d to a string

      //repeat the same 3 steps from the other operator on the resulting string

      return *this;
   }

   int getcount()
   {
      return numChars;
   }

   int getchecksum()
   {
      return arithmeticSum;
   }
private:

   //member variables to keep track of the information we need to output at the end
   int arithmeticSum;
   int numChars;
};

One thing I didn't include here is mention of the endl operator. But need to crawl before you can walk, so to speak.
 

Timedog

good credit (by proxy)
I am getting back into programming after a long break and ran into something super confusing that probably has a simple answer.

In this code, in the function Fill Course, without the bolded "cout << endl;", strlen(course) does not store a c-string correctly, and I have no clue why. Can someone explain this behavior

Code:
#include <iostream>
#include <CSTRING>
#include <fstream>

using namespace std;

void Fill_Course( char course[] );
//void Fill_Description( char description[] );
//void Fill_Date( char date[]);

int main()
{
    bool quit = false;
    int choice;

    char course[6];
    char description[50];
    char date[11];

    ifstream inFile;
    ofstream outFile;


    cout << "Hello, welcome back to your personal organizer program!" << endl;

    while(quit ==  false)
    {
        cout << "Press a number 1-4 to select an option!" << endl << endl
            << "(1) Add a new task" << endl
            << "(2) Display all tasks" << endl
            << "(3) Find a task by course name" << endl
            << "(4) Exit application" << endl << endl;

        cin >> choice;
        cin.ignore(10000,'\n');

        if (choice == 1)
        {
            Fill_Course( course );
            //Fill_Description();
            //Fill_Date();
        }

    }
}


void Fill_Course( char course[] )
{
    int i;
    ofstream outFile;
    
    [B]cout<< endl;[/B] //the cout in question. If I erase this cin.get doesn't function correctly for some reason
    
    outFile.open("tasks.txt");
    cout << "What is the name of the course for this task? ";
    cin.get(course, strlen(course)+1);
    cout<< "string length now = " << strlen(course) << endl; //code to see what strlen(course) is outputting


    for (i = 0; i < strlen(course); i++)
    {
        outFile << course[i]; //prints c-string to file
        cout << course[i]; // to see what course[] is storing
    }

    outFile << " ; "; //adds space between next input

    outFile.close();

    return;
}

Secondly, whenever I run the program it overwrites whatever was already written on the output file. I want it to start writing to the file at the end of the last line of text in the file, instead of overwriting everything. How do I achieve this.
 
Secondly, whenever I run the program it overwrites whatever was already written on the output file. I want it to start writing to the file at the end of the last line of text in the file, instead of overwriting everything. How do I achieve this.

You're just creating the file every time. You need to tell it to append. Syntax should be

open (filename, ios::app);
 

Timedog

good credit (by proxy)
You're just creating the file every time. You need to tell it to append. Syntax should be

open (filename, ios::app);

Oh god, of course! Hmmm, but how do I associate the file with the ofstream variable? Would it be like:

Code:
ofstream outFile

outFile.open("tasks.txt", ios::app)

?

edit: that seemed to work, thanks!

BUT...simply adding ", ios::app" in that argument fucks my program up again in the same way the adding the "cout << endl;" fixed--strlen outputs a value of 2 for the length of course[] when I type a 4 or 5 character word in. Erasing that extra append parameter makes the program function normally again. Makes no fucking sense. :(
 

Slavik81

Member
strlen goes through a char array until it finds a null character '\0'. You've not initialized your course array, so it contains random data. There may be no null character, and strlen will run off the end of the array.

I'd recommend declaring your arrays like this to initialize them with zeroes:
Code:
	char course[6] = {0};
	char description[50] = {0};
	char date[11] = {0};

However, then you cannot just use strlen to check how long they are. If you want to use them as you're using them now, you'd have to do something more like this:

Code:
	char course[6];
	course[5] = '\0';
	char description[50];
	description[49]='\0';
	char date[11];
	date[10]='\0'
EDIT: Now using a char literal, rather than an int literal.


BUT...simply adding ", ios::app" in that argument fucks my program up again in the same way the adding the "cout << endl;" fixed--strlen outputs a value of 2 for the length of course[] when I type a 4 or 5 character word in. Erasing that extra append parameter makes the program function normally again. Makes no fucking sense. :(

Where the string arrays happen to be put in memory will affect how your program runs as it exists now. You've invoked the dreaded 'undefined behaviour'. Otherwise inconsequential changes to your program could have all kinds of effects.
 

Slavik81

Member
There may be other problems, actually. I'm just identifying the one that caused the program to crash when I ran it.

I'm looking up the documentation on cin.get right now, since I'm not particularly familiar with the standard library streams. I'll explain further in a bit.

EDIT: Ok. cin.get extracts n-1 characters. strlen returns the size of the buffer - 1. So actually the number of characters extracted in your case is strlen+1-1. The null terminator stays null. That bit seems fine.
 

Slavik81

Member
Egad. Use std::getline with a std::string instead of cin.get.

I'd second that. std::strings are a million times easier to work with than char arrays. I was presuming that you were using them for a reason, but if you aren't being forced to do things that way, it would certainly be easier to switch.
 

Timedog

good credit (by proxy)
Egad. Use std::getline with a std::string instead of cin.get.

If I could use strings my program would have been finished a long time ago :'(

Code:
    char course[6];
    course[5] = '\0';

Appears to fix the problem. What happens if some of the "random" data in one the previous indexes happens to read as '\0'? Is there some small chance of that happening, the odds given by how many bits it takes to store a character? (this is probably my complete non-understanding of how data works).
 

Slavik81

Member
You're correct that's an issue. I certainly hadn't thought that entirely through. In that case, it won't crash, but the maximum length of the string you accept will be even shorter. Possibly even 0.

You could initialize the rest to something non-zero, but really I'd recommend initializing the entire thing to null and not depending on strlen to try to remember its length. Pass around the size of the buffer as a seperate variable.
 

Timedog

good credit (by proxy)
So when I initialize the char array, do something like this

Code:
int courseBuffer = 6
char course[courseBuffer]

Ugh, this is soooooooo stupid. And now I have to read a sentence from input stream with spaces without getline? That'll be fun to figure out...

edit: OH SHIT. For some reason I thought getline was only used with actual strings. Sweeeet: http://www.cplusplus.com/reference/iostream/istream/getline/
 

Timedog

good credit (by proxy)
Okay, so I am not creating files with multiples lines. Taking data from the user, then doing a \n after their input, and new pieces of data are stored on different lines. Now I am trying to read this data from the file, and print it. I am running into behavior that I cannot understand again =/. Here is my function for printing the data:

Code:
void Task_Printer()
{
    char printArray[75];
    ifstream inFile;
    int i;

    inFile.open("tasks.txt");

    while ( inFile.eof() == false);
    {
        inFile.getline(printArray, 75, '\n');
        cout << printArray << endl;
    }

    return;
}

It does not enter the while loop unless I make inFile.eof == true, at which point it prints out the first line in the file, exits the while loop, then exits the function. It's saying that when at the beginning of the file, it's at the end, and then when going to a new line, it's saying it's not longer at the end of the file, and exiting the while loop.

Super confused =/.
 

Blizzard

Banned
Manually dealing with character arrays is the bane of mankind. Ugh.
What's horribly sad is that I have done this for so long since I sometimes work with C programs, I literally had to read up on how C++ was magically converting a char* array to std::string last night. It turned out it was due to a constructor, and C++ being allowed one implicit conversion since the constructor wasn't marked "explicit" or something like that. I don't know that I had encountered the "explicit" keyword much before either.

I don't think I had ever even messed with the explicit keyword before. :( I try to avoid anything to do with the std:: library in general, though I suppose it should be standard on most systems. Maybe it's because it was a bad idea due to hidden memory allocation on some embedded systems, or maybe because I didn't want exception handling, or maybe I'm just crazy. At any rate I'm so used to doing char arrays that other methods feel awkward to me and I would have to read up on API stuff, lol.
 
The program I'm writing is a game where the user has 20 attempts to guess the number I'm thinking. When attempting to compile the code I get an error

error: expected expression before &#8216;else&#8217;


I've searched google and think it has something to do with my bracketing but I've double checked and I can't see anything wrong. I've bolded the line of the error.

Code:
#include<stdio.h>
#include <math.h>

int main ()

{
	int v = 42;
	int g = 0;
	int i = 0;
	int r = 20 - i;

//Print Menu
	printf("Hello, lets play a game.\n I am thinking of a number and I'll give you 20 chances to quess the number that I am thinking.\n");


for (i = 1; i <= 20; i++)
{

	printf("Enter your Guess for the magic number:\n");
	scanf("$d", &g);

	if ( g == v )
	{
			printf("Guess number %d is: CORRECT\n", i);
	                break;
	}
	else if ( (g >= 32) && ( g <= 52) )
	{
			printf("Guess number %d is: On Fire\n", i);
	}	
	else if ( (g >= -58) && (g <= 142) );
	{
			printf("Guess number %d is: Steaming\n", i);
	}	
	[B]else if ( (g >= -958) && (g <= 1042) )[/B]
	{
			printf("Guess number %d is: Lukewarm\n", i);
	}	
	else if ( (g >= -9958) && (g <= 10042) )
	{
			printf("Guess number %d is: Frigid\n", i);
	}
	else if ( (g > -9958) && (g < 10042) )
	{
			printf("Guess number %d is: Near 0 Kelvin\n", i);
	}
	else
	{
			printf("You have %d guesses remaining\n", r);
	}
}
	
return 0;

}
 

dabig2

Member
The semicolon at the end in the else before your error line kills it.

This. Also as a design issue, you probably want to take the
Code:
printf("You have %d guesses remaining\n", r);
out of that if-else structure. You want to alert them of how many guesses remain after every guess I assume. So just place it at the end of the for loop outside the if-else blocks. The way you have it now, that statement never prints unless the user types in a number greater than 10042 or less than -9958. Not too helpful :p

Also, your variable r never changes. Since it depends on your iteration i, you also want to move that statement to inside your for loop (or better yet, just get rid of it and do the computation in the printf statement).

So the end of your for loop could look like this:
Code:
else if ( (g > -9958) && (g < 10042) )
	{
			printf("Guess number %d is: Near 0 Kelvin\n", i);
	}
	
 printf("You have %d guesses remaining\n", 20-i);
}

Oh, and another design issue could be just computing the difference between the user's guess and your number. This gets rid of hardcoding the range in your if-else statements. Something to think about.
 

Toby

Member
I have a question for c++ programmers out there. Have you ever heard of/used Message Passing Interface (MPI) in your work?
I'm taking a parallel programming course that seems entirely devoted to this instead of the broader ideas of writing parallel algorithms. I'm now really concerned if learning all this is going to be at all useful.
 
I have a question for c++ programmers out there. Have you ever heard of/used Message Passing Interface (MPI) in your work?
I'm taking a parallel programming course that seems entirely devoted to this instead of the broader ideas of writing parallel algorithms. I'm now really concerned if learning all this is going to be at all useful.

It might be useful if you're:

a) Writing a massively distributed system
b) An academic
c) Work for some government agency
d) Taking a course on parallel programming

On the other hand, most people in the industry dont even understand practical parallel programming either, so even if you were learning the more useful side of PP, you'd still find difficulty integrating these concepts and algorithms into any modern software project.
 

Slavik81

Member
I've heard of it in passing, mainly in comparison to DDS. Based on what I've seen, I'm not a tremendous fan. That looks like a very painful way to communicate.

Message Passing: Yea!
Message Passing Interface: Umm....

For parallel processing, we didn't even look at it, though. CUDA/OpenCL were the obvious choice for us. My impression is that CUDA/OpenCL's model is much, much easier to develop something useful in, though it may somewhat depend on your goal.
 

tokkun

Member
MPI is used a lot in scientific/defense fields. In my experience it's also harder to learn/use than the other parallel programming models, so maybe it will look good on the CV?

What broader ideas do you feel like you're missing? I think most companies are happy if you understand mutexes, semaphores, fences, and basic concepts of non-determinism/race conditions.
 
Status
Not open for further replies.
Top Bottom