473,408 Members | 2,477 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,408 software developers and data experts.

Please if you can help me by solving the following question by c++

12
i need help please this program in c and ineed someone to change it in to c++ (change the format).please i need it as soon as u can before tuesday:)


__________________________________________________ __
/* Problem 0: Write a paragraph read from a file to the screen
in a justified format, paragraph should end with . */

/* Include libraries */
#include <stdio.h>
#include<iostream>
#include <string.h>
using namespace std;


int i,j;
char temp1[1000],c;
FILE *in;

/* Excution Of Main Program Starts Here */
int main ()
{

in = fopen ("indata.dat","r");
if (in == NULL)
{

/* In case the file name does not exist, the following error
/* message will be displayed */

printf("Error : Couldn't open file indata.dat for reading...\n");
printf("Error : File does not exist... \n");
return 0;
}
else
{


/* Reading number of records in the file */


printf("\n The Justified Pharagraph is >> \n\n");
fscanf(in,"%[^.].",&temp1);


j=0;
while (j<500)
{
label_start:
while (temp1[j] == ' ')
j=j+1;
if (temp1[j] != '\n');
printf("\n %c",temp1[j]);
for (i=j+1; i<=j+60; i++)
{
if (temp1[i] == '.')
goto label_end;

if (temp1[i] == '\n')
{
j=i+1;
cout<<(c,temp1[i]);
goto label_start;
}
printf("%c",temp1[i]);
}
j=j+60;
}

label_end:
fclose(in);
printf("\n---------------------------------------------------------\n");
printf(" Thank You For Using My Program \n");
printf(" Have A Nice Day \n");
printf("---------------------------------------------------------\n");
getchar();
return 1;
}}

__________________________________________________ ______
the program read the paragraph from (txt.) and make the paragraph with justified . for example the paragraph is(This is program homework to be done in C++ language for the Clanguage course,it is realy interesting course which I livepooool enjoied it alot :)
I like programing languages...)
Jan 7 '07 #1
4 1428
Hello,
Assuming that ur display is 'c' wide. Read the input till 'c' characters are read. Count the number of words 'w'. If the cth character is in the middle of the word, pushback the characters till delimiter(space) is encountered. After each word, print w divide by c number of spaces.
Jan 8 '07 #2
baroon
12
?????????????????????????????????????!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!?????????????????????????????
Jan 8 '07 #3
Banfa
9,065 Expert Mod 8TB
?????????????????????????????????????!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!?????????????????????????????
You will get better answers if you give better replies. Explain what you don't understand.


You give a C (well nearly C) program to start with and say it must be changed to C++ but I would expect a simple C program of this nature to compile in C++ so all you need to do is rename the file from <whatever>.c to <whatever>.cpp

Be more specific in asking your questions, C/C++ programming to too wide a subject for people to be able to guess at the question you are trying to ask.
Jan 8 '07 #4
baroon
12
hi,
my doctor want from me to chang this program from c to c++



like printf we should change it in to cout<< ,

also we should add #include <iostream> ,

also there r some thing do same what (goto) do in c++ ??ets.
Jan 9 '07 #5

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

Similar topics

7
by: tyler_durden | last post by:
thanks a lot for all your help..I'm really appreciated... with all the help I've been getting in forums I've been able to continue my program and it's almost done, but I'm having a big problem that...
4
by: garyusenet | last post by:
i posted today my day has been totally fruitless. there must be someone out there that knows enough to figure this out?
16
by: Rex | last post by:
Hi All - I have a question that I think MIGHT be of interest to a number of us developers. I am somewhat new to VIsual Studio 2005 but not new to VB. I am looking for ideas about quick and...
4
by: naknak4 | last post by:
Introduction This assignment requires you to develop solutions to the given problem using several different approaches (which actually involves using three different STL containers). You will...
5
by: outofmymind | last post by:
Hi every1, im trying to solve this question, i did some of it but i dont think that its correct or complete: this is the question: Write the definition of a class called Product. A Product...
2
by: baroon | last post by:
Please if you can help me by solving the following question by >>using C++: >> >>One important function in word-processing system is typ >>justification the alignment of words to both the left...
62
by: vubaboota | last post by:
I HAVE SOME SERIOUS PROBLEM , HOW TO MAKE A PROGRAM IN C Q1: Write a program using malloc function. In which you take input from user and allocate memory equal to square of this number. Which...
6
by: jenipriya | last post by:
Hi all... its very urgent.. please........i m a beginner in oracle.... Anyone please help me wit dese codes i hv tried... and correct the errors... The table structures i hav Employee (EmpID,...
1
by: HypeBeast McStreetwear | last post by:
Hello everyone. I got a assignment that states. The set of linear equations a11X1 = a12X2 = c1 a21X1 = a22X2 = c2 May be solved using Cramer’s rule: X1 = c1a22 – c2a12 a11a22 –...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.