Assign string to TCHAR

I'm having getting error messages trying to do the following:

extern TCHAR ext_app_name[MAX_PATH];
// Try to overwrite the value
ext_app_name = _T("http://www.myurl.com/home.html");

But I'm getting the following error message:

error: incompatible types in assignment of `const wchar_t[72]'  to `TCHAR[260]'

Thanks!
LVL 1
mybluegrassAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

evilrixSenior Software Engineer (Avast)Commented:
ext_app_name is an array not a pointer so you need to copy the string into the array not assign it like a pointer.
0
mybluegrassAuthor Commented:
In the code, how come this line works fine:

TCHAR ext_app[MAX_PATH*4]=_T("\"");
 _tcscat(ext_app,ext_app_name);

Doesn't ext_app have the same type as ext_app_name? If _T("\"") can be assigned to ext_app, I thought a regular string can be assigned to ext_app_name as well.

Thanks!

Ming
0
evilrixSenior Software Engineer (Avast)Commented:
That works because you're doing it at definition time. That's the only time you are allowed to assign like that. See the difference between...

TCHAR ext_app[MAX_PATH*4]=_T("\"");

and

extern TCHAR ext_app_name[MAX_PATH];
ext_app_name = _T("http://www.myurl.com/home.html");

In the 2nd case you are not doing the assignment on definition.
0
cupCommented:
For the assignment, use

_tcscpy (ext_app, _T("whatever"));
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.