What's the output from this program using fork() and why?

Whats wrong with my code C++. The question follows.?

  • The main function of the incomplete program below initialises the variables name, addr1, addr2 and postalCode and then calls function displayData to display the name and address as follows: Mr R.S. Bopape P.O. Box 50741 Sandton 2146 Your task is to write the void function displayData. Compile and run your program and submit the program and the output. The code i wrote looks like this: #include <iostream> #include <string> using namespace std; void displayData (string nameP, string addr1P, string addr2P, sring postalCodeP) { cout<<nameP<<endl; cout<<addr1P<<endl; cout<<addr2P<<endl; cout<<postalCodeP<<endl; } int main() { string name, addr1, addr2, postalCode; name = "Mr R.S.Bopape"; addr1 = "P.O. Box 50741"; addr2 = "Sandton"; postalCode = "2146"; displayData(name, addr1, addr2, postalCode); system ("PAUSE"); return 0; }

  • Answer:

    The only real problem I see is that the type declaration for "postalCodeP" is "sring". You probably meant "string".

Timothy C at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

Nothing wrong with the code. Probably, postal code would have declared as an integer. As such no problem. It gets compiled and executes

James Bond

May be you are using an outdated compiler. TC3 or some other old compiler. It does not c++ standards. Get a modern compiler and try..

Dream Window

well check the spelling of string and dude try removing SYSTEM and check... That system is your problem..

chiku

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.