Flour and cornstarch are two different things, but that doesn't mean there aren't times they can't be substituted for each other. Depending on the recipe, it is sometimes possible to swap out flour for cornstarch, or vice versa. In general, you can substitute flour for cornstarch, but you'll have to use twice as much, which will make the resulting dish heavier and thicker than the recipe intends.
A better solution would be to substitute another starch, such as arrowroot, potato starch, tapioca starch, or even rice flour.
Ordinary flour is made from wheat, and it contains protein, starch, and fiber. The protein, known as gluten, is what causes the dough to become elastic when you knead it, and it gives baked goods their structure.
Cornstarch, on the other hand, is made from cornmeal which is processed to separate the protein and fiber, leaving just the starch. Since it's pure starch, you can't bake with it because it does not have any protein or fiber in it. While some people assume cornstarch is worse for your diet than flour, this belief isn't entirely founded. It lacks some of the vitamins in flour, but both are heavily processed carbohydrates, which when consumed in moderation, can be part of a balanced diet.
What Cornstarch Is Good For
Cornstarch is good for thickening foods like sauces, puddings, and pie fillings. That's because when it's cooked, a starch acts like a sponge, absorbing liquid and expanding as it does so. It also gelatinizes, which means it sets up firm when it cools, which is what you might want a cream pie filling to do.
All starches have this property, which is why flour is also used for thickening sauces (usually as part of a roux). But because it's pure starch, cornstarch has twice the thickening power of flour. So you would have to use twice as much flour to achieve the same thickening as cornstarch. However, too much flour will cause your sauce or filling to turn thick and gummy. It will also have a floury taste, which probably isn't what you want.
Additionally, cornstarch imparts a shiny, translucent appearance, which is a desirable feature for fruit pie fillings and certain sauces (especially in Chinese cuisine). Flour won't do this.
If you're attempting to keep to a gluten-free diet, then you'll want to stick to cornstarch over flour for a thickening agent. Cornstarch is made from corn which lacks gluten.
Deep-Frying With Cornstarch Instead of Flour
Cornstarch can also give deep-fried foods a crispy coating. This works because the cornstarch absorbs moisture from the food and expands, and then when the food is fried, the moisture cooks out of the cornstarch, leaving the crispy, the puffy coating on the outside.
Flour will do this to some extent, but again, you'll need to use more flour to achieve the same effect, and it will be a thicker, chewier coating, rather than the light, crispy one the cornstarch produces.