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 514589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:32:26+00:00 2026-05-13T07:32:26+00:00

I want to add a new (fstream) function in a program that already uses

  • 0

I want to add a new (fstream) function in a program that already uses char arrays to process strings.
The problem is that the below code yields strings, and the only way i can think of getting this to work would be to have an intermediary function that would copy the strings, char by char, into a new char array, pass these on to the functions in the program, get back the results and then copy the results char by char back into the string.

Surely (hopefully) there must be a better way?

Thanks!

void translateStream(ifstream &input, ostream& cout) {   
  string inputStr;
  string translated;

  getline(input, inputStr, ' ');

  while (!input.eof()) {
    translateWord(inputStr, translated);
    cout << translated;
    getline(input, inputStr, ' ');
  }

    cout << inputStr;

the translateWord func:

void translateWord(char orig[], char pig[]) {
  bool dropCap = false;
  int len = strlen(orig)-1;
  int firstVowel = findFirstVowel(orig);
  char tempStr[len];

  strcpy(pig, orig);


  if (isdigit(orig[0])) return;


  //remember if dropped cap
  if (isupper(orig[0])) dropCap = true;        

  if (firstVowel == -1) {
    strcat(pig, "ay");
    //    return;
  }

  if (isVowel(orig[0], 0, len)) {
    strcat(pig, "way");
    //    return;
  } else {

    splitString(pig,tempStr,firstVowel);

    strcat(tempStr, pig);
    strcat(tempStr, "ay");

    strcpy(pig,tempStr);
  }


  if (dropCap) {
    pig[0] = toupper(pig[0]);
  }

}
  • 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-13T07:32:26+00:00Added an answer on May 13, 2026 at 7:32 am

    You can pass a string as the first parameter to translateWord by making the first parameter a const char *. Then you call the function with inputStr.c_str() as the first parameter. Do deal with the second (output) parameter though, you need to either completely re-write translateWord to use std::string (the best solution, IMHO), or pass a suitably sized array of char as the second parameter.

    Also, what you have posted is not actually C++ – for example:

    char tempStr[len];
    

    is not supported by C++ – it is an extension of g++, taken from C99.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 256k
  • Answers 256k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You should also allow for the option of "skipping" steps… May 13, 2026 at 10:35 am
  • Editorial Team
    Editorial Team added an answer Maybe this solutions can be util: $(document).ready(function(){ $(".img-caption").hover( function(){ $(this).find('p').show();… May 13, 2026 at 10:35 am
  • Editorial Team
    Editorial Team added an answer Python does, kind of: if x in [something, somethingelse]: ...… May 13, 2026 at 10:35 am

Related Questions

I have a file that I want to read and write to a binary
Hello I have written a such function under Eclipse: public static ArrayList<String> getMails(){ ArrayList<String>
I have 2 applications. One in C++ (windows) open a binary file and only
Say I have a couple of basic objects like so: [Serializable] public class Base
I want to add a new time-field to a an existing MySQL-table that is

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.