Created
April 20, 2018 14:59
-
-
Save alchem0x2A/d813517bbb8f7f08dd9f38ab9cfd66a0 to your computer and use it in GitHub Desktop.
Right Handle of Array Point with function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
// Return vector y = x * x | |
void manipulate(double *y, double *x, size_t n){ | |
/* x and y must be initialized! */ | |
std::cout << "Inside the function" << std::endl; | |
std::cout << "Size of x?: " << | |
sizeof(x) << " " | |
<< "Size of y?: " | |
<<sizeof(y) | |
<< std::endl; | |
for (size_t i=0; i< n; ++i) | |
y[i] = x[i] * x[i]; | |
} | |
int main() { | |
double y[5]; | |
double x[5] = {1.0, 2.0, 3.0, 4.0, 5.0}; | |
std::cout << "In the main function" << std::endl; | |
std::cout << "Size of x?: " << sizeof(x) << " " | |
<< "Size of y?: "<< sizeof(y) | |
<< std::endl; | |
manipulate(y, x, 5); | |
std::cout << "x is:" << std::endl; | |
for (size_t i=0; i< 5; ++i) | |
std::cout << x[i] << " "; | |
std::cout << std::endl; | |
std::cout << "y is:" << std::endl; | |
for (size_t i=0; i< 5; ++i) | |
std::cout << y[i] << " "; | |
std::cout << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment