Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

203
Visualizações
changing while loops to for loops

I'm trying to change this while loop into a for loop and I'm not getting particularly far. I am new ish to programming, so apologies if this is a trivial task.

while (read < fileBytes.length
       && (numRead = diStream.read(fileBytes, read, fileBytes.length - read)) >= 0)
{
    read = read + numRead;
}
over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

Try to use this :

start_value = //....
for (read = start_value; read < fileBytes.length 
        && (numRead = diStream.read(fileBytes, read, fileBytes.length - read)) >= 0; 
        read += numRead) {

    //Your actions

}
over 4 years ago · Santiago Trujillo Relatório

0

I'm a C# Programmer, but I will write code which is very similar to what you need.

for (int read = 0; read < fileBytes.length;) {
    numRead = diStream.read(fileBytes, read, fileBytes.length - read);
    if (numRead >= 0) {
        read = read + numRead;
    }
}
over 4 years ago · Santiago Trujillo Relatório

0

for(numRead = diStream.read(fileBytes, read, fileBytes.length - read);
read < fileBytes.length && numRead >= 0;
numRead = diStream.read(fileBytes, read, fileBytes.length - read)) {
      read = read + numRead;
}
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda