February 25, 2007 problems printing a dchar | ||||
---|---|---|---|---|
| ||||
this code will result on a win32 exception when trying to writefln "nomeEnt" import std.stdio; import std.intrinsic; import std.stream; import std.string; int main() { ushort tamanho; ubyte[] buffer1, buffer2; dchar[255] nomeEnt='\0', nomeSai; writef("Introduza o tamanho da matrix de encriptacao: "); scanf("%d", &tamanho); buffer1.length=tamanho*tamanho; buffer2.length=tamanho*tamanho; writef("Introduza o nome do ficheiro a encriptar: "); scanf("%s", &nomeEnt); writef("Abrindo " ); getch(); writefln(nomeEnt); //File fichEnt=new File(nomeEnt, FileMode.In); //buffer1.length=0; //buffer2.length=0; return 0; } Also, changing "dchar" to "char" will print the string, but will also cause the program to throw "invalid UTF-8 sequence. Suggestions? |
February 25, 2007 Re: problems printing a dchar | ||||
---|---|---|---|---|
| ||||
Posted in reply to Orgoton | Orgoton wrote:
> this code will result on a win32 exception when trying to writefln "nomeEnt"
>
> import std.stdio;
> import std.intrinsic;
> import std.stream;
> import std.string;
>
> int main()
> {
> ushort tamanho;
> ubyte[] buffer1, buffer2;
> dchar[255] nomeEnt='\0', nomeSai;
> writef("Introduza o tamanho da matrix de encriptacao: ");
> scanf("%d", &tamanho);
> buffer1.length=tamanho*tamanho;
> buffer2.length=tamanho*tamanho;
> writef("Introduza o nome do ficheiro a encriptar: ");
> scanf("%s", &nomeEnt);
> writef("Abrindo " );
> getch();
> writefln(nomeEnt);
> //File fichEnt=new File(nomeEnt, FileMode.In);
> //buffer1.length=0;
> //buffer2.length=0;
> return 0;
> }
>
> Also, changing "dchar" to "char" will print the string, but will also cause the program to throw "invalid UTF-8 sequence. Suggestions?
scanf doesn't work with utf-32. Try looking at std.cstream instead.
|
Copyright © 1999-2021 by the D Language Foundation