Quantcast
Channel: Intel Communities: Message List
Viewing all articles
Browse latest Browse all 20984

Re: how to read data from a txt file from sd

$
0
0

Hi Intel_Jesus

I've triedyourcode,is of greathelp,my question is:justread the codesaved aswellif:
90
150
200
215
320
420
520

infile "servo.txt"

  1. file= fopen("/media/realroot/servo.txt" , "rt");  
  2. if (file) {  
  3. while (fgets(line, 100, file) != NULL){ 
  4.     sscanf (line, "%ld", &Value); 
  5.     printf ("%ld\n", Value); 
  6.     array[count] = Value; 
  7.     count++; 
  8.     }  

may be it'sbecausethefgets() function; onlyrunsuntil it findsa number,iffor example,myfile issavedin this way:
90,150,200,215,320,420,520onlywould printthe value90, because afterthisone "," andthefgets() function; only recognizesnumbers.

And myidea would be. thusaccommodate90,150,200,215,320,420

eachseparationby commasis aservofor example the firstservorevicivethe value ofthe 90 secondservorevivesvalue150...
And so onuntilservo#6
this functioncould beoccupyingString.IndexOf(val, from)

Description

Locates a character or String within another String. By default, searches from the beginning of the String, but can also start from a given index, allowing for the locating of all instances of the character or String.

Syntax string.indexOf(val)

string.indexOf(val, from)

Parameters

string: a variable of type String
val: the value to search for - char or String
from: the index to start the search from

Regards,

 

 


 


 



Viewing all articles
Browse latest Browse all 20984

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>