problems printing a dchar

Orgoton orgoton at mindless.com
Sun Feb 25 14:24:04 PST 2007


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?



More information about the Digitalmars-d mailing list