C Language Problem: Arithmetic & Fileread() Function

In summary, the conversation discusses the possibility of performing arithmetic operations between float and int variables. It is confirmed that this is possible using type promotion. The conversation also mentions four functions - fileread(), getline(), readfile(), and fread() - and the question is asked about which function can read the number of elements from a file. It is clarified that two of the functions are present in stdio.h, but two are not. The suggestion is made to use grep or another tool to check the content of stdio.h and io.h. It is also mentioned that this may be a multiple choice quiz question with two dummy functions that do not exist and two real functions, and users are advised to use grep to find the answer.
  • #1
rclakmal
76
0

Homework Statement



1Can we perform arithmetic operations between float and int variables ,
As an example can we say a+b while a is an integer and b is a float.

2 And what function below will read NUMBER of elements from a file?
fileread( )
getline( )
readfile( )
fread( )


Homework Equations





The Attempt at a Solution

 
Physics news on Phys.org
  • #2
rclakmal said:
As an example can we say a+b while a is an integer and b is a float.

Yes. Look for type promotion.

fileread( )
getline( )
readfile( )
fread( )

C? stdio.h?
 
  • #3
stdio.h header file is there ! i want to know what function will read number of elements from file ?/
 
  • #4
read can do it. Trick is, you are listing functions that as far as I remember are not present neither in io.h nor stdio.h, so I have no idea what you refer to.
 
  • #5
Borek said:
read can do it. Trick is, you are listing functions that as far as I remember are not present neither in io.h nor stdio.h, so I have no idea what you refer to.

Two of them are in stdio.h, and one of them is for reading a given number of elements from a FILE stream.
 
  • #6
Yes, two are present - but two are not.
 
  • #7
Borek said:
Yes, two are present - but two are not.

I think it must be a simple multichoice quiz question with two dummy functions that sound plausible and don't exist, and two real functions... only one of which does what is asked.
 
  • #8
To some extent that's what I supposed at first, but - as such functions do exist in some languages/libraries - I wasn't sure what the question really is about; hence my attempt at clarificatin of the situation.
 
  • #9
rclakmal said:
stdio.h header file is there ! i want to know what function will read number of elements from file ?/

Use grep, egrep or fgrep to look for definitions of those four functions in stdio.h. You should be able to figure it from there.
 
  • #10
sylas said:
I think it must be a simple multichoice quiz question with two dummy functions that sound plausible and don't exist, and two real functions... only one of which does what is asked.

Yr exactly ...it is the case Its a MCQ .So what will be the answer help please .
 
  • #11
rclakmal said:
Yr exactly ...it is the case Its a MCQ .So what will be the answer help please .

Before there was google, there was grep to answer everything... :wink:

grep stdio.h for the function definitions... or use man
 
  • #12
You have mentioned that two functions here exist and others do not .so please tell me which one exists.
 
  • #13
Use grep or any other tool to check the content of stdio.h and io.h, we will not spoonfeed you.
 
  • #14
oh thanks so much for ur VALUABLE advice !it was a great help!
 

Related to C Language Problem: Arithmetic & Fileread() Function

1. What is the C language problem related to arithmetic?

The C language problem related to arithmetic refers to the issue of precision and rounding errors that can occur when performing calculations in C. This is due to the fact that C uses a finite number of bits to represent numbers, leading to limitations in the accuracy of calculations.

2. How can I avoid arithmetic problems in C?

To avoid arithmetic problems in C, it is important to understand the limitations of the language and use appropriate data types for calculations. For example, using the "float" or "double" data types can provide more precision than the "int" data type. Additionally, using libraries or functions that handle floating-point arithmetic can also help minimize errors.

3. What is the fileread() function in C?

The fileread() function in C is a standard library function that allows for reading data from a file. It takes in a file pointer and the number of bytes to be read, and returns the data as a character array. This function is commonly used in programs that need to read and process data from external files.

4. How do I use the fileread() function in my code?

To use the fileread() function in your code, you first need to open the file you want to read using the fopen() function. Then, you can use the fileread() function to read the desired amount of data from the file. After you are done using the file, don't forget to close it using the fclose() function to avoid any potential errors.

5. Can the fileread() function cause arithmetic problems in C?

No, the fileread() function itself does not cause arithmetic problems in C. However, if the data being read from the file contains numerical values that are not properly handled, such as leading to overflow or underflow, it can contribute to arithmetic problems in the program. It is important to ensure that the data being read is properly formatted and handled in the code to avoid any potential issues.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
8
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
8
Views
2K
  • Programming and Computer Science
Replies
2
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
5
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
10
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
14
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
6
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
Back
Top