• Witaj na Forum Arduino Polska! Zapraszamy do rejestracji!
  • Znajdziesz tutaj wiele informacji na temat hardware / software.
Witaj! Logowanie Rejestracja


Ocena wątku:
  • 0 głosów - średnia: 0
  • 1
  • 2
  • 3
  • 4
  • 5
konwersja string do tablicy char
#2
o to wypociny dzisiejszej nocy udało mi się odczytać dane do osobnych kolumn i oto właśnie mi chodziło ale jest problem ze to zmienna string jak zrobić konwersje do char
Kod:
#include <SPI.h>
#include <SD.h>

File myFile;
char dana;
String bufor;
char buforst[504];




long i;
void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }


  Serial.print("Initializing SD card...");

  if (!SD.begin(4)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");


  // re-open the file for reading:
  myFile = SD.open("test.txt");
  if (myFile) {
    Serial.println("test.txt:");

    // read from the file until there's nothing else in it:
    while (myFile.available()) {
                     for(int b=0;b<4;b++){
                            dana=myFile.read();
                            bufor=bufor+String(dana);
                          
                                }
                                 Serial.println(bufor);
                               i++;
                          //     buforst[i]=bufor;
                          Serial.println(i);
                                bufor.toCharArray(buforst, 504) ;
                            //   buforst[i]=char(bufor);
                              
                                bufor="";
                          
                               }
                               for(int b=0;b<504;b++){
                               Serial.println(buforst[b]);
                               }
    // close the file:
    myFile.close();
  } else {
    // if the file didn't open, print an error:
   }
}

void loop() {
  // nothing happens after setup
}
pomoże ktos
[Obrazek: banerelektronika.jpg]



Jeśli pomogłem podziękuj punktem reputacji Wink
 
Odpowiedź
  


Wiadomości w tym wątku
konwersja string do tablicy char - przez adix - 24-05-2016, 21:02
RE: konwersja string do tablicy char - przez adix - 25-05-2016, 21:05

Skocz do:


Przeglądający: 1 gości