C Language Problem: Arithmetic & Fileread() Function

AI Thread Summary
Arithmetic operations can be performed between float and int variables in C due to type promotion, allowing expressions like a + b where a is an integer and b is a float. For reading a specific number of elements from a file, the functions listed include fileread(), getline(), readfile(), and fread(), with only fread() being valid for this purpose. The discussion suggests using tools like grep to check the definitions of these functions in the stdio.h header file. Participants clarify that some listed functions do not exist in standard libraries, indicating a potential quiz format with misleading options. Overall, the conversation emphasizes understanding function availability and type promotion in C programming.
rclakmal
Messages
76
Reaction score
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
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?
 
stdio.h header file is there ! i want to know what function will read number of elements from file ?/
 
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.
 
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.
 
Yes, two are present - but two are not.
 
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.
 
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.
 
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!
 

Similar threads

Back
Top