Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 274
  • Last Modified:

getting values from input.txt

input.txt;

-1 0 -1 2 3
1 -1 3 -1 4
...
...

i try to get values from txt. i got pozitive integers but i cant get -1. if it is -1 , i am going to do something.

this sample input.txt file can be change, not unique.

thanks.
0
thefirstfbli
Asked:
thefirstfbli
  • 5
  • 4
1 Solution
 
ozoCommented:
how are you getting them?
are you using scanf with a %d format?
0
 
thefirstfbliAuthor Commented:
yes, i try fgets too.

i cant do it because of it is not unique txt. it may different.
0
 
ozoCommented:
why is being different a problem?
what kinds of differences can there be?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
thefirstfbliAuthor Commented:
i try to say; different txt inputs, -1 can be anywhere in txt.

like

0 1 2 3 -1
3 11 -1 3
1 -1 2 4
.. .. .. ect
0
 
thefirstfbliAuthor Commented:
but there wont be a -2, -3 ...ect

 only negative number that will be there is -1. i need all pozitives too.
0
 
ozoCommented:
why is that a problem?
0
 
thefirstfbliAuthor Commented:
the problem is;

first of all i want to see the integers with printf for ex;

for second txt;

array[0]=1, array[1]=2, array[3]=3, array[4]=-1
array2[0]=3, array[1]=11, .... ect.

i want to print them first of all, i try to do more complex thing with these numbers.
0
 
ozoCommented:
for( i=0;i<=4; i++ ){
  fscanf(INPUTFILE,"%d",&array[i]);
}
for( i=0;i<=4; i++ ){
  printf("array[%d] = %d, ",i,array[i]);
}
0
 
thefirstfbliAuthor Commented:
ow.. it takes negative sign.. i did not understand but yes works.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now