Can we use strings with scanf?

Rempas rempas at tutanota.com
Mon Jan 25 18:43:18 UTC 2021


On Monday, 25 January 2021 at 18:28:09 UTC, Ferhat Kurtulmuş 
wrote:
> On Monday, 25 January 2021 at 17:38:21 UTC, Rempas wrote:
>> On Monday, 25 January 2021 at 10:33:14 UTC, Mike Parker wrote:
>>> [...]
>>
>> Thanks! Actually for some reason. It won't accept a 
>> char[size]. I created a heap allocated (with pureFree and 
>> pureMalloc) chrar*, then used fgets() and created an empty 
>> string and looped through the result adding one by one 
>> character until the '\n' which is not included.
>
> char[buffsize] works if buffsize is a compile time constant. Or 
> just char[1024]. İt is a static array, and it's size must be 
> defined at compile time.

Idk, for my it says that you can't pass dynamic arrays to scanf


More information about the Digitalmars-d-learn mailing list