char cwd<1024>;if (getcwd(cwd, sizeof(cwd)) != (char*)NULL) printf("%sn",cwd);else error_print("error in pwd");how and what do I need to fix?


Do you encompass unistd.h? If not, the error shows up because her C compiler is presume getcwd returns int.

You are watching: Warning: comparison between pointer and integer

The fix? encompass unistd.h


*

Sydius outlined the types reasonably well:

Normal pointers are just that - they point to some point in memory somewhere. Who owns it? only the comments will certainly let girlfriend know. Who frees it? hopefully the owner at part point.Smart pointers room a blanket term the cover many types; I"ll i think you intended scoped tip which supplies the RAII pattern. That is a stack-allocated object that wraps a pointer; as soon as it goes out of scope, the calls delete on the reminder it wraps. The "owns" the had pointer in the it is in fee of deleteing the at part point. They enable you to get a raw recommendation to the pointer they wrap because that passing to various other methods, and also releasing the pointer, permitting someone rather to very own it. Copying them does no make sense.Shared pointers is a stack-allocated object that wraps a guideline so the you don"t need to know that owns it. As soon as the last common pointer for things in storage is destructed, the wrapped reminder will additionally be deleted.

How about when you should use them? You will certainly either make hefty use the scoped needle or mutual pointers. How many threads are running in your application? If the price is "potentially a lot", mutual pointers can turn the end to be a power bottleneck if used everywhere. The factor being the creating/copying/destructing a mutual pointer demands to be an atomic operation, and also this have the right to hinder power if friend have plenty of threads running. However, that won"t always be the instance - only experimentation will tell you for sure.

There is an discussion (that ns like) against shared pointers - by using them, friend are allowing programmers to neglect who owns a pointer. This can lead come tricky instances with circular referrals (Java will certainly detect these, but shared needle cannot) or basic programmer laziness in a huge code base.

There are two reasons to usage scoped pointers. The an initial is for an easy exception safety and also cleanup to work - if you desire to guarantee that an object is cleaned up no matter what in the challenge of exceptions, and you don"t want to ridge allocate that object, placed it in a scoped pointer. If the operation is a success, you can feel totally free to transport it over to a shared pointer, however in the meantime conserve the overhead with a scoped pointer.

See more: How To Print Without Black Ink Epson Printer Print Without Black Ink

The other case is when you want clear object ownership. Some teams favor this, some perform not. Because that instance, a data structure might return needle to inner objects. Under a scoped pointer, it would certainly return a raw guideline or referral that should be treated together a weak referral - the is an error to access that guideline after the data structure that owns it is destructed, and also it is one error come delete it. Under a shared pointer, the owning object can"t destruct the internal data it went back if who still stop a handle on it - this might leave resources open for much much longer than necessary, or much worse depending upon the code.