Pointer cause overhead?

Does uses of pinter in char type cause extra overhead?
Huh? I don't understand the question. Can you give an example?
I believe he means using C strings, and he believes the dereferencing of these may yield and overhead. Which is not really the case, C++ strings (std::string) is generally preferred these days, unless you're dealing with a lot of C functions, you can easily cast C++ strings into C strings.

Don't worry about it. :) It's very efficient. You could do it a few billion times, and it would still be in the nanoseconds range on my laptop.
Extra overhead compared to what? Everything has overhead. You need to compare it with something else to be able to say something useful about the overhead.
I meant which is fatser char* name="name" or char name[10]="name"

by the way i cannot assign like this:

char *name;
cin>>*name; //deference to hold value
cout<<*name<<endl; //show value

it says segment fault :(
how can I input to pointers characters for example?
As for your first question, speed isn't a factor. Those are constants that are allocated at compile-time. The '10' in the second example isn't necessary by the way, and I'm pretty sure that the fist one is deprecated with out stating that it is const.

As for your second question:
char *name; only allocates a pointer, it does not allocate memory for the pointer to point to. In practice, use "std::string" or "std::wstring" they are standard for a reason. Academically speaking, you would use the 'new' operator like this:
1
2
3
char* name = new char[ARBITRARILY_LARGE_VALUE_OR_NON-CONST_VARIABLE_GOES_HERE];
//CODE CODE CODE...
delete [] name; //When You Are Done With 'name' 

The only advantage here is that you do not have to know the size of the array at compile time, however "std::string" provides the exact same advantage plus a number of very useful member functions.
I meant which is fatser char* name="name" or char name[10]="name"
Actually the first one is just barely a little bit faster, because it doesn't copy anything.
It doesn't really matter, though, because they do different things.
thanks all
Topic archived. No new replies allowed.