I have a program in which i open a a text file, access it's values and create and array with it. for example the text file may contain these values:
1 44 3 4 33 6 7 8 61 10
; that's 10 integers
what c++ tools could i use to count the number of integer values in the file? i want it so that it runs through the text file and counts 10 integers
teddyg18 0 Newbie Poster
Recommended Answers
Jump to PostI have a program in which i open a a text file, access it's values and create and array with it. for example the text file may contain these values:
1 44 3 4 33 6 7 8 61 10
; that's 10 integers
what c++ tools could i use …
Jump to PostThis seems to be a different spec than originally mentioned. Here's what I originally had in mind:
const int MAX_SIZE = 100; int array[MAX_SIZE]; int numIntegers = 0; while (inFile >> array[numIntegers]) { numIntegers++; }
This assumes everything in the file is an integer and there …
Jump to PostAnother thread where the OP got a pre-cooked pudding(tasteless though).
All 12 Replies
VernonDozier 2,218 Posting Expert Featured Poster
wildgoose 420 Practically a Posting Shark
teddyg18 0 Newbie Poster
wildgoose 420 Practically a Posting Shark
VernonDozier 2,218 Posting Expert Featured Poster
siddhant3s 1,429 Practically a Posting Shark
teddyg18 0 Newbie Poster
teddyg18 0 Newbie Poster
VernonDozier 2,218 Posting Expert Featured Poster
teddyg18 0 Newbie Poster
VernonDozier 2,218 Posting Expert Featured Poster
teddyg18 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.