From kde-devel Sun Jun 24 09:44:35 2001 From: Malte.Starostik () t-online ! de (Malte Starostik) Date: Sun, 24 Jun 2001 09:44:35 +0000 To: kde-devel Subject: Re: (Off topic) warning: ANSI C++ forbids variable-size array `theData' X-MARC-Message: https://marc.info/?l=kde-devel&m=99338079403925 On Sonntag, 24. Juni 2001 07:19, Ian Reinhart Geiser wrote: > Greetings, > I have a question on the correct way of doing things. > I have a byte array that is a char[]. The problem is i do not know the > length until runtime. I have always done this but C++ is not suppose to > be this way. > > Currently I am doing the following: > > char data[blockSize]; // Is there a better way to do this.... > theFile->at(theSession->getIndex()); > int newbytesWritten = theFile->readBlock(data, blockSize); > > I know there is a better way to do this, but I cannot find it right now. > Any suggestions? QByteArray data(blockSize); theFile->at(theSession->getIndex()); int newbytesWritten = theFile->readBlock(data.data(), blockSize); With QByteArray you can also easily resize the data etc. -Malte -- .globl main; main: .long 0x90909090,0xdb311deb,0x89d98843,0x89e2d3da,0x01e0d3d0,0x92548dc2 .long 0x80cd5902,0xd889db31,0xe880cd40,0xffffffde,0x206c6c41,0x72756f79 .long 0x73614220,0x72412065,0x65422065,0x676e6f6c,0x206f7420,0x0a217355 >> Visit http://master.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<