473,396 Members | 1,900 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,396 software developers and data experts.

Building logic in C++

151 100+
Actaully i have data in file like this

&#^!&*^$*&^!$*&^!*&^$
ACBDBCAAHDADHKADHKJAH
+++------------+++++++---
32137847894738947984774
&*($@&(&(&@$&($&@(#&
JKAHFKJAHFLKAJFHKAHFJKHF
+++-------------+++++++--
48932478974894789744747

while reading a file, i want to get the result in such a way that Alphabatical line should be first one to print and other three line should be concatenated so result wil be like
Ist line ACBDBCAAHDADHKADHKJAH
IInd line &#^!&*^$*&^!$*&^!*&^$+++------------+++++++--32137847894738947984774
IIIrd line JKAHFKJAHFLKAJFHKAHFJKHF
IVth line
&*($@(&@$($&@(#&+++-------------+++++++--48932478974894789744747

I have tried a lot every time the format is coming different. I m not getting the correct format.
Oct 20 '08 #1
5 1206
r035198x
13,262 8TB
Post a short description of the algorithm you used for this.
Oct 20 '08 #2
Man4ish
151 100+
Algorithm:
This is not the actual syntax, just a pseudocode.

read a file line by line
char s[500]=="\0";

if(isalpha(line))
{
cout<<line;
if(s!="\0")
cout<<s;
s="\0";
}
else
{
strcat(s,line);
}
Oct 20 '08 #3
JosAH
11,448 Expert 8TB
You're almost there: you have to come up with a little function that checks whether
or not a line only contains alpha(numeric)s and play a bit with reading entire
lines from an input stream.

There's one dangerous section in your code: how do you make sure that your
buffer is large enough when you append another line to it?

kind regards,

Jos
Oct 20 '08 #4
Man4ish
151 100+
Actaully the code is not giving the correct output ,i have already played a lot.
it is giving output like
Ist line &#^!&*^$*&^!$*&^!*&^$
IInd line ACBDBCAAHDADHKADHKJAH
IIIrd line +++------------+++++++---32137847894738947984774&*($@&(&(&@$&($&@(#&
IVth line JKAHFKJAHFLKAJFHKAHFJKHF
Vth line +++-------------+++++++--48932478974894789744747


As Far as buffer is concerned i can keep it as 9999 instead of 500 and also can use assert for checking, that is not a pblm. But the main pblm is this only.
Manish
it is giving the first line
You're almost there: you have to come up with a little function that checks whether
or not a line only contains alpha(numeric)s and play a bit with reading entire
lines from an input stream.

There's one dangerous section in your code: how do you make sure that your
buffer is large enough when you append another line to it?

kind regards,

Jos
Oct 20 '08 #5
JosAH
11,448 Expert 8TB
Show us your actual code then; we can't keep on guessing what you *might* have
done incorrectly.

kind regards,

Jos
Oct 20 '08 #6

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

Similar topics

4
by: Rasjid Wilcox | last post by:
I am wanting to write a database application using Python. I want it to be GUI agnostic. The GUI will probably be Python/wxPython, but I would also like the option of a Webbased (PHP?) gui, and...
7
by: aleksander.helgaker | last post by:
I'm learning to program python on my Mac and I'd like some help. I followed a tutorial which showed how to make a calculator for working out the area of a shape. E.g. the area of a circal is...
0
by: Mac MCCall | last post by:
I am doing work for a community that currently has four different MS-Access databases which are at four separate locations but have a great deal of overlapping data. There is a residents...
0
by: Stylus Studio | last post by:
Hi Everyone, A new XML tutorial by Dr. Kay was just released, "Buiding XML Workflow Applications". Dr. Michael Kay argues that the bulk of the application logic required for typical XML...
7
by: Hal Vaughan | last post by:
I have a problem with port forwarding and I have been working on it for over 2 weeks with no luck. I have found C programs that almost work and Java programs that almost work, but nothing that...
3
by: JezB | last post by:
I kind of understand the ASP.NET architecture in terms of building web pages with embedded server controls, where the .aspx is run on the client and the ..aspx.cs runs on the server. But what if...
1
by: Robert Neville | last post by:
Basically, I want to create a table in html, xml, or xslt; with any number of regular expressions; a script (Perl or Python) which reads each table row (regex and replacement); and performs the...
4
by: =?Utf-8?B?Uml6d2Fu?= | last post by:
In the system I am working on, there are 3 credit cards: Visa, MasterCard and AmericanExpress. On the database side I have one table: credit_card CREATE TABLE credit_card ( credit_card_id int...
7
Curtis Rutland
by: Curtis Rutland | last post by:
Building A Silverlight (2.0) Multi-File Uploader All source code is C#. VB.NET source is coming soon. Note: This project requires Visual Studio 2008 SP1 or Visual Web Developer 2008 SP1 and...
11
by: tfurubay | last post by:
Hi, I am building a form and i would like it to have conditional error messages. For instance, I am creating a Date field. If the date field is populated, I also need Field 2 populated and an...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.