read from sd card

hey guys i try to read certain words from text file in sd card
the fille is something like 2000 chars and i want to read just few words
how i can do it?
thanks in advance

can you explain more

can you explain more

1. The above is the SD card that the OP has connected with his/her UNO. If you wish, you can also do it. This is an good opportunity to learn the interfacing of SD card with UNO?

2. The SD card already contains a text file which contains 2000 characters. Let us assume that the OP knows the name of his file as (Myfile.txt), and he wants to read only 5 characters from the beginning of the file and save them into a character array named saveData[5];.

3. You have to execute the following algorithms:
(a) Include the SPI.h and SD.h files
(5) Declare variables as needed.
(c) Initialize SD card and check that it has been initialized.
(d) Open the existing file by its name. Note down the file pointer so returned by the .open method.
e) Read 5 bytes data from the SD card in the form of 5 characters and save them in an array.
(f) Close the file.

4. You may collect the required C instructions/functions from the following sample (working) program:


//C function prototype: char *strcat(char *dest, const char *src);
char src[] = "GolamMostafa";   //global because of const in the function prototype
char  saveRead[50] = "AUST";//data will be saved here that will be read from SD card
char x[50];
int i=0;

File myData;              //File pointer for the file to be opened in SD Card
const int chipSelect = 10; //CS-pin of SD Card is connected to DPin-10 of UNO

void setup() 
  //strcat(saveRead, src);        //dest array contains GolamMostafa ; Mostafa is appended at the end of Golam
 // Serial.println(dest);    //SM prints: GolamMostafa 
  if (!SD.begin(chipSelect)) 
    Serial.println("Card failed, or not present");//SD Crad initialization. 
    // don't do anything more:
  Serial.println("card initialized.");
  SD.remove("Testfile.txt");     //remove if any file named Testfile.txt exists
  myData ="Testfile.txt", FILE_WRITE);   //file named Testfile.txt opened for writing
  myData.println(src);     //GolamMostafa is written into SD Card
  myData.close();           //the file being pointed by pointer myData is closed
  myData ="Testfile.txt", FILE_READ);   //file named Testfile.txt opened for reading
  while (myData.available()!=0)
    x[i] = (char);   //x[] contains ASCII codes of characters coming from SD
    Serial.print(x[i]);              //show charctaers on SM (Serial Monitor)
  myData.close();                 //file closed
 strcat(saveRead, x);    //the content of an array can be appended at the end of another array
 Serial.print(saveRead);       //SM prints: ASUtGolamMostafa

void loop()