[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: (Off topic) warning: ANSI C++ forbids variable-size array `theData'
From:       Rik Hemsley <rik () kde ! org>
Date:       2001-06-24 10:32:58
[Download RAW message or body]

#if Ian Reinhart Geiser
> 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(), data.size());

Rik
 
>> Visit http://master.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic