C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old August 31st, 2004, 04:16 PM
webmanc webmanc is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 4 webmanc User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 51 sec
Reputation Power: 0
Question How do I open a file and read data into

How do I open a file and read data into an array i have a file named wordfind.in this is what my file looks like below. I am attempting to read in the information in the fist paragraph into a 2 demintional array and then compare the information in the array with the string of words to see if i can find a match in the random matrix. Here is my code and what i have writen so far can any one offer help?

cenad

aatps

rnrpj

hello

wmneo



hello

apple

car

me

men

ran

woman



#include <iostream>

#include <fstream>

#include <string>

#include <cassert>

usingnamespace std;

int main()

{

//Greeting

cout << "\nFinds a given set of words in a square table filled\n"

"with single letters.As well as the direction in which the\n"

"word is oriented (N, NE, E, SE, S, SW, W, NW). If a word\n"

"does not occur, then the line should contain the word and\n"

"then NOT FOUND.\n";



ifstream inStream;

inStream.open(wordfind.in());

assert(wordfind.in.is_open());

for(;

{

inStream >> reading;

if(reading.eof()) break;

}

inStream.close();



}


Reply With Quote
  #2  
Old September 1st, 2004, 03:55 PM
pmxer pmxer is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: Normal IL
Posts: 4 pmxer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to pmxer
well first of all you should be opening the file with this syntax:

inStream.open("c:filename.txt");

im not sure if assert is even works but i know you could alternativly do:

if(in.fail())
{
cout << "Opening the file failed.";
system("pause");
exit(1);
}

i have no idea what your doing with that for statment. if you have more questions post ill try to answer what i can.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > How do I open a file and read data into


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT