473,379 Members | 1,530 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Problem with my c assignment

5
Hi guys i need help... im trying to make this program, to count the number of paragraphs found in a particular text file. 10x
Nov 28 '07 #1
4 1249
seforo
60
So .....? Where is the problem? What have you done?
Nov 28 '07 #2
keoo
5
i have done dis part :-

Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4.  
  5. int main () 
  6. {
  7.   string line;
  8.   ifstream myfile ("C:\\keo.txt");
  9.   if (myfile.is_open())
  10.   {
  11.     while (! myfile.eof() )
  12.     {
  13.       getline (myfile,line);
  14.       cout << line << endl;
  15.     }
  16.     myfile.close();
  17.   }
  18.  
  19.   else cout << "Unable to open file"; 
  20.  
  21.  
  22.   getchar ();
  23.   return 0;
  24.   }
and im finding problems to make it count the lines
Nov 28 '07 #3
weaknessforcats
9,208 Expert Mod 8TB
You have no counter in your loop.

Also, if you have to count paragraphs, how are you to identify a parargraph??
Nov 28 '07 #4
oler1s
671 Expert 512MB
Have you even being going to class? You can't even get the code you posted correct. It's not minor mistakes either. Let's see: use of stdio.h and stdlib.h. For one thing, C headers are written as something like <cstdio> and <cstdlib> . You use something like string and getline (in <string>) and cout (<iostream>) and ifstream (<fstream>). Your use of eof is problematic, and you will see the last line in the file repeating twice.

I'm going to outright accuse you of not knowing the material, and trying to wing it. You haven't done a thing. Open a book, and start reading. We won't do your homework for you; see the posting guidelines.
Nov 28 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: August1 | last post by:
I've written an interface and implementation file along with a client source file that allows the use of an overloaded subtraction operator. However, when using the program, I'm running into a...
7
by: Jef Driesen | last post by:
Suppose I have an abstract base class that looks like this: template <typename T> class base { public: // Typedefs typedef double value_type; typedef std::size_t size_type; public: //...
14
by: Fredda | last post by:
Hello! I have problem with the following: >From the class 'Transaktion': ------------------------------------------------------------------------------------------------------ .. .. ..
78
by: Josiah Manson | last post by:
I found that I was repeating the same couple of lines over and over in a function and decided to split those lines into a nested function after copying one too many minor changes all over. The only...
10
by: toton | last post by:
Hi I have a class called Session, which stores a vector of Page, like vector<PageAlso each Page need's to know the Session to which it is attached. Thus I have, (the classes has many other...
2
by: toton | last post by:
Hi, I am trying to use boost::range with one of my own container class, and having some problem. I am missing some usage of range. Can anyone suggest a proper way for it ? To show the problem...
7
by: dragoncoder | last post by:
Hello experts, I have the following code me. =cat mystring.h #include<iostream> using namespace std; class mystring {
7
by: pallav | last post by:
I'm having some trouble with my copy constructor. I've tried using gdb to find the bug, but it seg faults in the destructor. I'm not able to see what I'm doing wrong. Since I'm using pointers, I...
15
by: vivekian | last post by:
Hi, I have this following class class nodeInfo ; class childInfo { public: int relativeMeshId ;
1
by: yccheok | last post by:
Hello all, I am confused on the correct assignment operator that should be implemented on the derived class. I refer to the document found at :- ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.