473,748 Members | 11,134 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need help with this program

/* Remove.c
** Usage: remove < In_file Out_file (using redirection)
*/
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
char c;
int space = 0;

for(c = fgetc(stdin); !feof(stdin); c = fgetc(stdin)){
if((c !=' ')&&(space == 0)) /* start from beginning of line reading
in characters */
{
continue; /* we wan't to discard 'ii ' from beginning of line */
}
if(c ==' '){ /* space found, so increment counter */
space++;
}
if((space == 1)&&(space != 2)){ /* one space found so far... */
fputc(c, stdout); /* start printing characters until we reach
the second space */
}
if(space == 2){ /* second space found */
fputc('\r', stdout); /* mark as end of line */
space = 0; /* reset space counter */
}
if((space >= 2)&&(c !='\r')){ /* we don't need rest of line to the
'\r' mark */
continue; /* get rid of versions, descriptions, ect. */
}
}
return 0; /* we've read the entire file at this point, so we're at
the end */
}

/
*************** *************** ********(CUT)** *************** *************** ***********
I'm using the linux GCC 4.2.1 Compiler. I also have the Borland
V5.02.
This is only a very short sample of the KNOPPIX LINUX LIVE DVD
packages description.
I need to strip the 'ii ' at the beginning, the version, and package
description.
What's needed is the package name ONLY, so that I can edit the list
to create
a 'KICK LIST file.
The output file should be like:
-------------------------------------------------------------------------------------------
Own
aalib-bin
aalib1
ace-of-penguins
acpi
adduser
........
........
........
and so on.
----------------------------------------------------------------------------------------------
Any Suggestions would be welcomed.
Thanks in advance,
Wayne Andrews

packages.txt
||=NAME======VE RSION========== ==PACKAGE
DESCRIPTION==== ==============| |
ii 0wn 0.1-1 0wn - Knoppix
installer
ii aalib-bin 1.4p5-22 sample programs
using aalib
ii aalib1 1.4p5-28 ascii art
library - transitional package
ii ace-of-penguins 1.2-8 Solitaire-games
with penguin-look
ii acpi 0.09-1 displays
information on ACPI devices
ii adduser 3.101 Add and remove
users and groups
ii adtool 1.2-3 command line
utility for Active Directory administration
ii aespipe 2.3b-4 AES-encryption
tool with loop-AES support
ii afio 2.5-4 archive file
manipulation program
ii airsnort 0.2.7e-2 WLAN sniffer
ii alevt 1.6.1-7.1 X11 Teletext/
Videotext browser
ii alien 8.64 install non-
native packages with dpkg
ii alsa-base 1.0.13-2 ALSA driver
configuration files
ii alsa-utils 1.0.13-1 ALSA utilities
ii amanda-client 2.5.1p1-2.1 Advanced
Maryland Automatic Network Disk Archiver (Client)
ii amanda-common 2.5.1p1-2.1 Advanced
Maryland Automatic Network Disk
*/
Dec 11 '07 #1
3 1338
In article <d4************ *************** *******@t1g2000 pra.googlegroup s.com>,
<wd********@emb arqmail.comwrot e:
>************** *************** *********(CUT)* *************** *************** ************
I'm using the linux GCC 4.2.1 Compiler. I also have the Borland
V5.02.
This is only a very short sample of the KNOPPIX LINUX LIVE DVD
packages description.
I need to strip the 'ii ' at the beginning, the version, and package
description.
What's needed is the package name ONLY, so that I can edit the list
to create
a 'KICK LIST file.
The output file should be like:
-------------------------------------------------------------------------------------------
Own
aalib-bin
aalib1
[snip]
>packages.txt
||=NAME======V ERSION========= ===PACKAGE
DESCRIPTION=== =============== ||
ii 0wn 0.1-1 0wn - Knoppix
installer
ii aalib-bin 1.4p5-22 sample programs
using aalib
[snip]

Use The Right Tool For The Job.
"awk '{print $2}'" should work quite nicely, since you seem to be
working on some kind of *nix.
dave

Dec 11 '07 #2
On Dec 11, 2:19 pm, dj3va...@csclub .uwaterloo.ca.i nvalid wrote:
In article <d40f2ee9-4d6f-489d-ab95-050924053...@t1 g2000pra.google groups.com>,

<wdandre...@emb arqmail.comwrot e:
*************** *************** ********(CUT)** *************** *************** ***********
I'm using the linux GCC 4.2.1 Compiler. I also have the Borland
V5.02.
This is only a very short sample of the KNOPPIX LINUX LIVE DVD
packages description.
I need to strip the 'ii ' at the beginning, the version, and package
description.
What's needed is the package name ONLY, so that I can edit the list
to create
a 'KICK LIST file.
The output file should be like:
-------------------------------------------------------------------------------------------
Own
aalib-bin
aalib1

[snip]
packages.txt
||=NAME======VE RSION========== ==PACKAGE
DESCRIPTION==== ==============| |
ii 0wn 0.1-1 0wn - Knoppix
installer
ii aalib-bin 1.4p5-22 sample programs
using aalib

[snip]

Use The Right Tool For The Job.
"awk '{print $2}'" should work quite nicely, since you seem to be
working on some kind of *nix.

dave
Agree, awk is meant for text processing. It can give you a more
elegant and simple solution
Dec 11 '07 #3
wd********@emba rqmail.com wrote:

I'll avoid commenting on what I (but perhaps not everyone here)
would regard as horrible style, but:
if((space == 1)&&(space != 2)){ /* one space found so far... */
If space == 1, then it's definitely != 2; the second test is
completely unnecessary.

--
Trivia Hedgehog
"Based on their behaviour so far -- I have no idea" /Sahara/

Dec 11 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3115
by: Spamtrap | last post by:
I only do occasional Perl programming and most things I write are short processes. I have something I'm working on that is scanning a text file with about 15 million lines and trying to extract matches from another text file, which has about 170 entries. The second text file is read into an array. The process then scans through the big file for certain possible patterns - it will find those in about 1 out of 25 lines,, when it finds one,...
2
2868
by: aj902 | last post by:
Hello , I am trying to create a program where all detail, http://www.albany.edu/~csi333/projects.htm
13
2467
by: vgame64 | last post by:
Hi, I have been struggling with writing a program for a few hours. The requirements are that: """You will be writing a program which will determine whether a date is valid in terms of days in that month. We are assuming that the year will be valid 4 digit integer. So you don't have to think much about that(in terms of validation) except for the month of February. If the month is February, then you have to check whether that year is Leap...
4
2211
by: robinsand | last post by:
My apologies to those of you who are more advanced Visual C++ .NET programmers, but I am working on a project for an MBA course that is condensed into an eight-week schedule, and I need help getting a program up and running with proper files and documentation to be handed in for a grade (on Microsoft Visual Studio .NET 2003). I am being graded on how well I incorporate advanced C++ features such as inheritance, polymorphic programming,...
16
2537
by: pamelafluente | last post by:
I am still working with no success on that client/server problem. I need your help. I will submit simplified versions of my problem so we can see clearly what is going on. My model: A client uses IE to talk with a server. The user on the client (IE) sees an ASP net page containing a TextBox. He can write some text in this text box and push a submit button.
8
2747
by: skumar434 | last post by:
i need to store the data from a data base in to structure .............the problem is like this ....suppose there is a data base which stores the sequence no and item type etc ...but i need only the sequence nos and it should be such that i can access it through the structure .plz help me .
4
2201
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 implement all three techniques as programs. In these programs, as well as solving the problem, you will also measure how long the program takes to run. The programs are worth 80% of the total mark. The final 20% of the marks are awarded for a...
6
2126
by: naknak | 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 implement all three techniques as programs. In these programs, as well as solving the problem, you will also measure how long the program takes to run. The programs are worth 80% of the total mark. The final 20% of the marks are awarded for a...
1
5686
by: peterggmss | last post by:
This is a slot machine game, 2 forms. One is the actual game (frmMachine) and the other is in the background and randomizes the images shown on frmMachine. I need to make frmMachine wait for frmRandom, i tried it with the Sleep API and a Do/Until Loop and neither worked, could you please help me, I have my code below. frmMachine 'Slot Machine, (c) 2006 Peter Browne, GPL Licensed ' 'Peter Browne 'Sheridan Corporate Centre '2155 Leanne...
1
1969
by: raghavshastri | last post by:
You are to write a C++ program to perform a statistical analysis of the blobs in an image. The image will be a grayscale image in PGM format for simplicity. Here is a sample PGM image with 10 columns and 4 rows: P2 # Comment lines # They follow the P2 line. # There could be 0, 1 or more 10 4 255
0
8989
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9537
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9367
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9243
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8241
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3309
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2213
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.