About 10,100,000 results
Open links in new tab
  1. C++ how to pass string array in function and assign to a variable?

    Apr 1, 2018 · You can not assign array of strings string a[] to array courseTaken using = operator. The expression string a[] is equivalent to std::string*. That is why you get the compiler error. …

  2. Pass Array to Functions in C++ - GeeksforGeeks

    Jan 3, 2024 · In C++, we have the following ways to pass an array as a parameter to the function: 1. Passing as a Sized Array. In this method, we pass the array in the same way we declare it …

  3. C++ Passing Arrays as Function Parameters (With Examples)

    In C++, we can pass arrays as an argument to a function. And, also we can return arrays from a function. Before you learn about passing arrays as a function argument, make sure you know …

  4. Passing in and returning a string array - C++ Forum - C++ Users

    Mar 14, 2011 · If you want std::string you should include <string> ( without .h ) You are returning an array from a function returning a single string. From the way you are using arrays, I'd …

  5. Pass Array of Strings as Function Parameter - Stack Overflow

    Aug 8, 2016 · I need to pass a pre-allocated array of strings as a function parameter, and strcpy () to each of the strings within the string array, as in this example: static void string_copy(char * …

  6. Array of Strings in C++ - GeeksforGeeks

    Feb 26, 2025 · The general syntax of array of strings is: string arr_name[size] where arr_name is the name assigned to the array and size is the desired size. Understanding how to create and …

  7. Is passing a char array into a function that accepts string ... - Reddit

    Sep 8, 2022 · Take the following function signature: char *fgets(char *str, int n, FILE *stream) fgets accepts char * and not a char array? So suppose I have a char array, say char string[3], …

  8. How to pass an array of strings in C++ - Stack Overflow

    Apr 23, 2014 · void CommandInterpreter(string * array, unsigned int items_in_array, unsigned int array_capacity); Or void CommandInterpreter(std::vector<std::string>& array); // Much simpler …

  9. How to pass an array of strings as a function argument? - C++

    A string is nothing else but an char array: Code: char *myString; myString = malloc(6 * sizeof(char)); strcpy(myString, "hello"); OR char myString[] = "hello";

  10. Passing char array into a function - C++ Forum - C++ Users

    Oct 10, 2013 · Both functions should take zero-terminated strings as input. The first function should return the length of the string to the calling function. The second function should take a …

Refresh