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

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======VERSION============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 1321
In article <d4**********************************@t1g2000pra.g ooglegroups.com>,
<wd********@embarqmail.comwrote:
>**************************************(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======VERSION============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.invalid wrote:
In article <d40f2ee9-4d6f-489d-ab95-050924053...@t1g2000pra.googlegroups.com>,

<wdandre...@embarqmail.comwrote:
**************************************(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======VERSION============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********@embarqmail.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
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...
2
by: aj902 | last post by:
Hello , I am trying to create a program where all detail, http://www.albany.edu/~csi333/projects.htm
13
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...
4
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...
16
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...
8
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...
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...
6
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...
1
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...
1
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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:
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
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...
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,...
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.