How to use pointer to float in C++

1 Answer

0 votes
#include <iostream>

using std::cout;
using std::endl;

int main()
{
	float *f;

	f = new float;

	if (!f) {
		cout << "Allocation error" << endl;
		return 1;
	}

	*f = 3.14;

	cout << *f << endl;

	delete f;

	return 0;
}

/*
run:

3.14

*/

 



answered May 23, 2018 by avibootz

Related questions

1 answer 134 views
134 views asked May 13, 2021 by avibootz
1 answer 164 views
164 views asked Oct 6, 2019 by avibootz
1 answer 210 views
6 answers 367 views
367 views asked May 25, 2018 by avibootz
1 answer 171 views
...