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 139 views
139 views asked May 13, 2021 by avibootz
1 answer 170 views
170 views asked Oct 6, 2019 by avibootz
1 answer 225 views
6 answers 387 views
387 views asked May 25, 2018 by avibootz
1 answer 176 views
...