May 14, 2017 Re: File Input | ||||
---|---|---|---|---|
| ||||
Posted in reply to JV | On Sunday, 14 May 2017 at 04:15:02 UTC, JV wrote:
> Hey i'm not sure if i should create a new post for this but
> how should i fix this it doesn't pause and store but just keeps reading
>
> string studNum;
>
> readf("%s",&studNum);
> write(studNum);
Can you say exactly what you need?
It is better to be familiar with C and File in C, then using File in D
However, do not hesitate about asking, just feel free and ask
|
May 14, 2017 Re: File Input | ||||
---|---|---|---|---|
| ||||
Posted in reply to JV | On 05/13/2017 09:15 PM, JV wrote: > it doesn't pause and store but just keeps reading > > string studNum; > > readf("%s",&studNum); > write(studNum); That's the normal behavior for reading into strings. If you want to read to the end of the line, try this: import std.stdio; import std.string; void main() { write("What is your name? "); string name = readln.strip; writeln("Hello ", name, "!"); } (It's the same as strip(readln()).) Here is more information about readln() and strip() as well as formattedRead(), which can be more convenient: http://ddili.org/ders/d.en/strings.html Ali |
Copyright © 1999-2021 by the D Language Foundation