flat assembler
Message board for the users of flat assembler.

flat assembler > High Level Languages > [solv]how to reserve an extra space at the end of a string?

Author
Thread Post new topic Reply to topic
vivik



Joined: 29 Oct 2016
Posts: 425
Something like this:

wchar_t* filename = L"C:\\folder1\\folder2\\folder3\\",0,0,0,0,0,0,0,0;

I need to reserve space for 16 more characters, how? I can just write another 16 characters of whatever, but I'd prefer them to be 0.


Last edited by vivik on 25 Feb 2018, 06:17; edited 1 time in total
Post 24 Feb 2018, 08:32
View user's profile Send private message Reply with quote
alexfru



Joined: 23 Mar 2014
Posts: 63
"...\0\0\0"
Or if you use an array, making it big enough will work:
wchar_t filename[100] = L"C:\\folder1\\folder2\\folder3\\";
Post 24 Feb 2018, 09:15
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 15977
Location: Qo'noS
Use the constants that come with your OS. For Windows:
Code:
wchar_t filename[MAX_PATH] = L"C:\\folder1\\folder2\\folder3\\";    
There is no sense using more than MAX_PATH since the OS won't be able to use it. And always check that whatever you add to the buffer won't overflow it past MAX_PATH. It can cause some terrible bugs if you assume that your path length + 16 characters will never overflow past MAX_PATH.
Post 24 Feb 2018, 09:40
View user's profile Send private message Visit poster's website Reply with quote
vivik



Joined: 29 Oct 2016
Posts: 425
It looks like this string ends up read-only. Can I make it writable? Compiler is VS2005.

I guess I'll just copy it somewhere for now, it's not important.
Post 24 Feb 2018, 13:54
View user's profile Send private message Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1603
Location: Ukraine
MAX_PATH may appear short for UNICODE functions. It is not bad to read this to clarify the subject.
Post 24 Feb 2018, 15:00
View user's profile Send private message Visit poster's website Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2302
Location: Usono (aka, USA)
vivik wrote:
It looks like this string ends up read-only. Can I make it writable? Compiler is VS2005.


readonly wrote:

wchar_t* filename = L"C:\\folder1\\folder2\\folder3\\",0,0,0,0,0,0,0,0;


writeable? wrote:

wchar_t filename[100] = L"C:\\folder1\\folder2\\folder3\\";
Post 24 Feb 2018, 22:30
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2018, Tomasz Grysztar.

Powered by rwasa.