w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to pass array of structures to function in c++

Two ways I know of to pass arrays to functions.

The way you have it:

void ShowRoutes(Route *routeList, int n, string title) { //... }


void ShowRoutes(Route routeList[], int n, string title) { //...

Either way you write the function, you would still call it the same way:

ShowRoutes(routeList, n, "Unsorted list: ");

But as others mentioned, would be a good idea to learn std::array and std::vector.

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.