Search Results

Search found 2 results on 1 pages for 'user248247'.

Page 1/1 | 1 

  • novice question file read

    - by user248247
    while(getline(fileIn,line)) { fileOut <<line<<endl; } while(getline(fileIn,line)) { if(fileIn,eof()) break; fileOut <<line<<endl; } i have tried both piece of code and it still reads past and does not break. can anyone tell me why? I am just reading from file and writing to it. thanks

    Read the article

  • function parameter used to store value

    - by user248247
    Hi, I have to define an interface. The API in my homework is stated below: int generate_codes(char * ssn, char * student_id); int denotes 0 or 1 for pass or fail. studentid is an output param should return a 6 digit id. ssn is a 9 digit input param they school program will take ssn's and use my code to generate the student id. now from an API perspective should I not be using const char * for both parameters. should the studentid not be passed in by reference? rather than by pointer? can someone tell me how i can easily use the pointer in my test app which uses my api to get the pointer such that it prints a std::string from a char *? my app code looks something like const char * ssn = "987098765" const char * studnt_id = new char [7]; int value = -1; value = generate_codes(ssn,studnt_id); std::string test(studnt_id); std::cout<<"student id= "<<test<<" Pass/fail= "<<value<<std::endl; delete [] studnt_id; return 0; I basically got an error about << not being compatible with the right hand side of the operand. When i changed the code to std::cout<<"student id= "<<test.c_str()<<" Pass/fail= "<<value<<std::endl; then it worked but i get garbage for the value. not sure how to do get the value form the pointer. THe value inside the function prints just fine. but when i try to print it outside of the function it prints garbage. Inside the above function I do set the studndt_id like so std::string str_studnt_id = studnt_id; should that make the address of the str_studnt point to the address of studnt_id and thus any changes I make to the value that its pointing to it should reflect outside the function?

    Read the article

1