Working With Pointers in C++: Potential Dangers and Hazards

The impact of the downturn on employment in the Food Manufacturing Industry today is worldwide. The US processed food sector had steady growth in the ten year period after 1997, with slight decline near the end. Many employed in the food manufacturing industry are multinationals. Growth in processed food goods can be attributed to several factors, including two income families, less time at home for food preparation, and more take home and restaurant food purchases. Over that ten year period, the value of food shipments increased about 27 percent.

Many smaller food manufacturing companies are hit harder by economic downturns. They employ fewer people in food jobs; pay more for food products, deliveries, and for manufacturing costs than large companies. The few large companies hire more multinationals, who account for about a third of all food industry jobs. About 89 percent of the smaller companies have less than 100 workers. Many smaller companies are swallowed up in acquisitions by large companies.

The impact of the economic downturn on employment in the Food Manufacturing Industry affects automation and technology purchasing also, as these allow companies to operate at even higher output levels with fewer employees, adding to less employment in food manufacturing jobs. Employment in that ten year period declined about 5 percent. Wages and salaries showed virtually no increase when compared to the general economy (US) which had a projected growth of 11 percent.

Supermarkets have added more prepared meals to their shelves, and people want ready to serve snacks and frozen entrees. This demand is caused by two parent or single parent working families who have possibly more income yet less time for food preparation. It is not uncommon for families to eat out several times a week on a regular basis instead of just on special occasions. An aging population and a dieting population has also contributed to the demand for convenience foods, ready to eat, and restaurant foods. As ethnic populations of countries change with immigration, so do demands on the food manufacturing industry. A green trend towards eating locally produced food, organic foods, and medical allergy problems also affect food product demands and manufacturing costs.

Rising cost of fuel such as gasoline has also caused the impact of the economic downturn on employment in the Food Manufacturing Industry. A worldwide jump in costs for grains and vegetables has caused shortages of certain products and high prices everywhere. Some industries, like milk in the UK, are cutting back products and employment as costs rise. The fight over corn and grains for food or fuel has costs skyrocketing, with a boomerang effect on items like beef, which not only has encountered rising costs for feed, but transportation and processing. The plumping of humans causes another increase in vegetable prices, as people want more products; it is a supply and demand plus costs situation there.

Rising cost of ingredients has put the hammer down on small companies, like mom and pop bakeries or bagel companies, because they are unable to absorb high prices of ingredients like flour or wheat. They raise prices, and may lay off employees to combat costs, where the larger producers can find ways to absorb increases in commodity prices. Combine the stress of food product demands with rising energy costs and any adverse weather conditions, and the industry cannot help but feel the pinch and react by lowering employment overall.

During the past few years, there have been several catastrophic weather events, such as hurricanes, tsunamis, and earthquakes, which have wreaked havoc in people's normal living conditions. The ability to obtain food, and to grow food is impacted by this, and with higher energy costs and higher food demands worldwide, the cost of all food products has risen. Competition between animals and humans is another factor, and so is competition between animal food stocks and fuel demands. Alternative energy sources, like solar and wind, and hybrid engines are one answer. To use food for fuel seems to go against basic human sensibilities and interest. Using corn and wheat to power machines instead of humans will only increase food prices and lessen employment in the industry.

For the future, there is widespread demand to get away from high costs of oil fuels, and to develop "free" fuels for powering machinery and electricity. Food production technology is an ongoing science that does increase output per acre, a major benefit to the world food supply. The weather, however, is beyond control. All that can be done in that area is better long term forecasting, and crop science improvements in output and planting techniques. There should be some increases in worldwide employment in those areas. The Food Manufacturing Industry, like many others in this modern age, must adjust and revise plans and make improvements to maintain its lifeblood.

Copyright (c) 2008 Ianson Internet Marketing

One of the most powerful tools provided in C++ for a programmer is pointers. Pointers in C++ are used to directly access different memory locations that are allocated while a program is being compiled and executed. This provides an enormous amount of flexibility, depth and strength to the program being written and adds another dimension to the object oriented paradigm.
However, as we all know from our childhood superhero comics: With great power comes great responsibility (God that sounded so cliché). Thus,
are a double-edged sword. A few of such pointer problems or
are memory leak or inaccessible memory and dangling pointers.
This article covers some main pointer hazards and the steps that should be taken by any C++ programmer to avoid such pointer hazards.
The main pointers hazards are:
1. Memory Leak
2. Dangling Pointer
3. Bad pointer
Memory leaks are a common occurrence in many C++ codes. Basically, this occurs when a pointer, already pointing at a memory block, let’s say ‘A’, is reallocated to another memory block, say, ‘B’. As the only way to access allocated memory blocks directly is through pointers, the first location, A, now becomes completely inaccessible memory, leading to a memory leak. As the compiler does not de-allocate memory by itself (the programmer has to use the delete keyword) and as our pointer is now pointing towards memory location B, this causes wastage of memory and resources of the system being used.
int *ptr = nullptr;
ptr = new int;
*ptr = 5;
ptr = new int;
Here, the memory space that stores the integer ‘5’ now cannot be accessed as the pointer ‘ptr’ is pointing towards another memory location now. As a result the space that the system uses for storing one integer is wasted until the end of program execution.
As a rule of thumb to avoid memory leak, always make sure the number of ‘delete’ and ‘new’ keywords in your program are equal, as every time you allocate a new memory using ‘new’, you need to de-allocate it using ‘delete’.

A dangling pointer is a pointer which points to a location in memory that is not a part of your program. It occurs when a programmer fails to point a pointer towards another memory location after using the ‘delete’ statement.

int *ptr = new int;
*ptr = 10;
delete ptr;
cout << *ptr;
Notice that here, the integer memory that was allocated to the pointer has been deleted but we are still trying to dereference the pointer and output its value. It may lead to very serious situations in your program leading to an infinite loop or a program crash.
Always initialize a pointer when creating it, otherwise it would become a bad pointer and point to any arbitrary location in the memory. Leaving this pointer uninitialized could lead to system crashes. As an uninitialized pointer points to a random memory location, this location could very well be a memory location previously used by another pointer, leading to major problems in the program.
int *ptr;
cout << *ptr;
Normally you should first initialize it to a NULL value and some other value later in your program. The new standard has created the keyword ‘nullptr’ for this purpose.
int * ptr = nullptr;
It is easy to see that pointers in C++ should be handled with extreme care and caution. There are many possibilities that may lead to crashes and bugs in your programs while using pointers, but if you try to avoid the pointers hazards mentioned above, you should be generally fine!!!