C Language Problem: Arithmetic & Fileread() Function

Click For Summary

Discussion Overview

The discussion revolves around performing arithmetic operations between different data types in C, specifically between float and int variables, and identifying which function can read a specified number of elements from a file. The scope includes homework-related questions and technical clarifications regarding C programming functions.

Discussion Character

  • Homework-related
  • Technical explanation
  • Debate/contested

Main Points Raised

  • Some participants assert that arithmetic operations between float and int variables are possible due to type promotion.
  • Several functions are proposed for reading elements from a file, including fileread(), getline(), readfile(), and fread().
  • One participant mentions that the functions listed may not all be present in the standard libraries, specifically io.h or stdio.h.
  • There is a suggestion that the question may be a multiple-choice quiz with plausible but non-existent functions included among real ones.
  • Another participant encourages using grep or similar tools to find definitions of the functions in stdio.h.
  • There is a request for clarification on which functions exist and which do not, indicating some uncertainty about the available functions.

Areas of Agreement / Disagreement

Participants express differing views on the existence of certain functions and their applicability, indicating that there is no consensus on which function is correct for reading a number of elements from a file.

Contextual Notes

Some participants express uncertainty about the question's intent and the existence of certain functions, suggesting that the discussion may depend on specific definitions or interpretations of the functions in question.

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

  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 3 ·
Replies
3
Views
6K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 4 ·
Replies
4
Views
5K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 14 ·
Replies
14
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 12 ·
Replies
12
Views
3K