Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

getting values from input.txt

Posted on 2006-11-30
9
249 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
ID: 18050222
how are you getting them?
are you using scanf with a %d format?
0
 
LVL 1

Author Comment

by:thefirstfbli
ID: 18050252
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
ID: 18050279
why is being different a problem?
what kinds of differences can there be?
0
Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

 
LVL 1

Author Comment

by:thefirstfbli
ID: 18050295
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
 
LVL 1

Author Comment

by:thefirstfbli
ID: 18050321
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
ID: 18050327
why is that a problem?
0
 
LVL 1

Author Comment

by:thefirstfbli
ID: 18050390
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
ID: 18050433
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
ID: 18050481
ow.. it takes negative sign.. i did not understand but yes works.
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
stack 22 169
My eclipse editor won't start ? 4 161
Adjust Mfcapp 29 171
Why  my code (program) build with old compiler? 11 75
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
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 recursion in the C programming language.

809 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