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 146 views
146 views asked May 13, 2021 by avibootz
1 answer 177 views
177 views asked Oct 6, 2019 by avibootz
1 answer 228 views
6 answers 401 views
401 views asked May 25, 2018 by avibootz
1 answer 183 views
...