Solved

getting values from input.txt

Posted on 2006-11-30
9
220 Views
Last Modified: 2010-04-15
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
Comment
Question by:thefirstfbli
  • 5
  • 4
9 Comments
 
LVL 84

Expert Comment

by:ozo
Comment Utility
how are you getting them?
are you using scanf with a %d format?
0
 
LVL 1

Author Comment

by:thefirstfbli
Comment Utility
yes, i try fgets too.

i cant do it because of it is not unique txt. it may different.
0
 
LVL 84

Expert Comment

by:ozo
Comment Utility
why is being different a problem?
what kinds of differences can there be?
0
 
LVL 1

Author Comment

by:thefirstfbli
Comment Utility
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 1

Author Comment

by:thefirstfbli
Comment Utility
but there wont be a -2, -3 ...ect

 only negative number that will be there is -1. i need all pozitives too.
0
 
LVL 84

Expert Comment

by:ozo
Comment Utility
why is that a problem?
0
 
LVL 1

Author Comment

by:thefirstfbli
Comment Utility
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
 
LVL 84

Accepted Solution

by:
ozo earned 400 total points
Comment Utility
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
 
LVL 1

Author Comment

by:thefirstfbli
Comment Utility
ow.. it takes negative sign.. i did not understand but yes works.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now