August 12, 2022 Re: My programs issues | ||||
---|---|---|---|---|
| ||||
Posted in reply to pascal111 | This is a program for duplicating files, I made some changes on it, and liked to share it may that I get a new advice on it: '''D module main; // D programming language import std.stdio; import std.string; import std.algorithm; import dcollect; int main(string[] args) { string s; //char[] f; string f1, f2, f3; for(size_t i=0; args[1].strmid(i, 1)!="."; i++) f1~=args[1].strmid(i, 1); for(size_t i=args[1].length-1; args[1].strmid(i, 1)!="."; i--) f2~=args[1].strmid(i, 1); f3=f1~" (DUPLICATED)."~f2.strreverse; try{ /*write("Enter file name and path: "); readln(f); f=strip(f);*/ File inputFile = File(args[1], "r"); File outputFile = File(f3, "w"); enum bufferSize = 8194; inputFile.byChunk(bufferSize) // read input in blocks of 8194 bytes .copy(outputFile.lockingBinaryWriter); // copy each block into output file inputFile.close(); outputFile.close(); } catch(Exception err){ stderr.writefln!"Warning! %s"(err.msg); return 1; } return 0; } ''' https://github.com/pascal111-fra/D/blob/main/duplicator2.d |
August 12, 2022 Re: My programs issues | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D Ruppe | On Wednesday, 10 August 2022 at 13:13:20 UTC, Adam D Ruppe wrote:
> On Wednesday, 10 August 2022 at 12:36:42 UTC, pascal111 wrote:
>> 1) I used "exit()" from "core.stdc.stdlib;" module, but someone can say this isn't the D way to exit the program.
>
> It is better to simply return a value from main instead.
>
>> 2) I used "goto", I heard from someone before that using "goto" isn't good programming feature.
>
> Don't listen to people who are wrong.
"goto" is a bad "structured programming" feature, but not a bad programming feature.
|
August 12, 2022 Re: My programs issues | ||||
---|---|---|---|---|
| ||||
Posted in reply to Antonio | On Friday, 12 August 2022 at 07:02:32 UTC, Antonio wrote:
> On Wednesday, 10 August 2022 at 13:13:20 UTC, Adam D Ruppe wrote:
>> On Wednesday, 10 August 2022 at 12:36:42 UTC, pascal111 wrote:
>>> 1) I used "exit()" from "core.stdc.stdlib;" module, but someone can say this isn't the D way to exit the program.
>>
>> It is better to simply return a value from main instead.
>>
>>> 2) I used "goto", I heard from someone before that using "goto" isn't good programming feature.
>>
>> Don't listen to people who are wrong.
>
> "goto" is a bad "structured programming" feature, but not a bad programming feature.
"structured programming" solved that with "while-like" loops.
|
August 12, 2022 Re: My programs issues | ||||
---|---|---|---|---|
| ||||
Posted in reply to pascal111 | On Thursday, 11 August 2022 at 20:30:54 UTC, pascal111 wrote:
> https://github.com/pascal111-fra/D/blob/main/proj08.d
btw letters :D
Please use ` (ASCII: 0x60) instead of ' (0x27) for the markdown format header, eg.:
```D ...```
otherwise it won't be recognized here.
|
August 12, 2022 Re: My programs issues | ||||
---|---|---|---|---|
| ||||
Posted in reply to frame | On Friday, 12 August 2022 at 16:06:09 UTC, frame wrote:
> On Thursday, 11 August 2022 at 20:30:54 UTC, pascal111 wrote:
>
>> https://github.com/pascal111-fra/D/blob/main/proj08.d
>
> btw letters :D
>
> Please use ` (ASCII: 0x60) instead of ' (0x27) for the markdown format header, eg.:
>
> ```D ...```
>
> otherwise it won't be recognized here.
I don't see "`" in the keyboard!
|
August 12, 2022 Re: My programs issues | ||||
---|---|---|---|---|
| ||||
Posted in reply to pascal111 | On Friday, 12 August 2022 at 18:43:14 UTC, pascal111 wrote: > On Friday, 12 August 2022 at 16:06:09 UTC, frame wrote: >> On Thursday, 11 August 2022 at 20:30:54 UTC, pascal111 wrote: >> >>> https://github.com/pascal111-fra/D/blob/main/proj08.d >> >> btw letters :D >> >> Please use ` (ASCII: 0x60) instead of ' (0x27) for the markdown format header, eg.: >> >> ```D ...``` >> >> otherwise it won't be recognized here. > > I don't see "`" in the keyboard! No doubt about that :D However, you can create the letter with your compose key (depends on your linux distribution, eg. [Shift] + [AltGr] but you may need to enable it first, see for example https://ubuntuhandbook.org/index.php/2019/02/enable-set-compose-key-ubuntu-18-04/ Maybe just pressing [Alt] and 9,6 on the NUM pad works too. |
August 12, 2022 Re: My programs issues | ||||
---|---|---|---|---|
| ||||
Posted in reply to frame | On Friday, 12 August 2022 at 19:18:38 UTC, frame wrote:
> On Friday, 12 August 2022 at 18:43:14 UTC, pascal111 wrote:
>> On Friday, 12 August 2022 at 16:06:09 UTC, frame wrote:
>>> On Thursday, 11 August 2022 at 20:30:54 UTC, pascal111 wrote:
>>>
>>>> https://github.com/pascal111-fra/D/blob/main/proj08.d
>>>
>>> btw letters :D
>>>
>>> Please use ` (ASCII: 0x60) instead of ' (0x27) for the markdown format header, eg.:
>>>
>>> ```D ...```
>>>
>>> otherwise it won't be recognized here.
>>
>> I don't see "`" in the keyboard!
>
> No doubt about that :D
>
> However, you can create the letter with your compose key (depends on your linux distribution, eg. [Shift] + [AltGr] but you may need to enable it first, see for example
>
> https://ubuntuhandbook.org/index.php/2019/02/enable-set-compose-key-ubuntu-18-04/
>
> Maybe just pressing [Alt] and 9,6 on the NUM pad works too.
I tried under Windows using alt+9 or 6 but with no hoped result, they printed another characters.
|
August 12, 2022 Re: My programs issues | ||||
---|---|---|---|---|
| ||||
Posted in reply to frame | On Friday, 12 August 2022 at 19:18:38 UTC, frame wrote:
> On Friday, 12 August 2022 at 18:43:14 UTC, pascal111 wrote:
>> On Friday, 12 August 2022 at 16:06:09 UTC, frame wrote:
>>> On Thursday, 11 August 2022 at 20:30:54 UTC, pascal111 wrote:
>>>
>>>> https://github.com/pascal111-fra/D/blob/main/proj08.d
>>>
>>> btw letters :D
>>>
>>> Please use ` (ASCII: 0x60) instead of ' (0x27) for the markdown format header, eg.:
>>>
>>> ```D ...```
>>>
>>> otherwise it won't be recognized here.
>>
>> I don't see "`" in the keyboard!
>
> No doubt about that :D
>
> However, you can create the letter with your compose key (depends on your linux distribution, eg. [Shift] + [AltGr] but you may need to enable it first, see for example
>
> https://ubuntuhandbook.org/index.php/2019/02/enable-set-compose-key-ubuntu-18-04/
>
> Maybe just pressing [Alt] and 9,6 on the NUM pad works too.
Maybe it'll be useful when I work on my Linux laptop, but the problem is still in Windows.
|
August 12, 2022 Re: My programs issues | ||||
---|---|---|---|---|
| ||||
Posted in reply to pascal111 | On Friday, 12 August 2022 at 20:16:26 UTC, pascal111 wrote:
> I tried under Windows using alt+9 or 6 but with no hoped result, they printed another characters.
Maybe this wasn't clear. I meant keep pressing [Alt] and then [9], [6] (in turn) and then release [Alt]. It should print the character (96 = 0x60)
|
Copyright © 1999-2021 by the D Language Foundation