Sponsored Content
Full Discussion: help with my program
Top Forums UNIX for Dummies Questions & Answers help with my program Post 302318160 by pangit_me on Thursday 21st of May 2009 12:56:11 AM
Old 05-21-2009
i'm actually writing an address book, i needed a script so sort it out alphabetically and search the entire file manually. it's like a phonebook function in a cellphone. it's sorted alphabetically and you can search for a certain name..

the problem is, i left my script at school since i can not access my account from home :|
i really you hope you can help me with this.
 

10 More Discussions You Might Find Interesting

1. Programming

Please need help with C program!

My program only ouputs the correct magic square sum totals for the number 15.If I enter any odd number smaller than 15 my sum totals are incorrect. I have define "size" to 15. How or what do I change so that my program will output the magic square results for the odd numbers 1 through 15 without... (1 Reply)
Discussion started by: JJJ
1 Replies

2. Programming

executing a program within a program

Read the title: how do i do it? (4 Replies)
Discussion started by: Gekko
4 Replies

3. Programming

How to write to stdin of another program (program A -> [stdin]program B)

Hi, Program A: uses pipe() I am able to read the stdout of PROGAM B (stdout got through system() command) into PROGRAM A using: * child -> dup2(fd, STDOUT_FILENO); -> execl("/path/PROGRAM B", "PROGRAM B", NULL); * parent -> char line; -> read(fd, line, 100); Question: ---------... (1 Reply)
Discussion started by: vvaidyan
1 Replies

4. UNIX for Dummies Questions & Answers

How to write to stdin of another program (program A -> [stdin]program B)

Hi, Program A: uses pipe() I am able to read the stdout of PROGAM B (stdout got through system() command) into PROGRAM A using: * child -> dup2(fd, STDOUT_FILENO); -> execl("/path/PROGRAM B", "PROGRAM B", NULL); * parent -> char line; -> read(fd, line, 100); Question: ---------... (3 Replies)
Discussion started by: vvaidyan
3 Replies

5. Programming

A program to trace execution of another program

Hi, I wanted to know if i can write a program using switches and signals, etc to trace execution of other unix program which calls c program internally. If yes how? If not with signals and switches then are there any other methods apart from debugging with gdb/dbx. (3 Replies)
Discussion started by: jiten_hegde
3 Replies

6. UNIX for Dummies Questions & Answers

Script to open program and send/execute command in program

Hi, i want to write a script that executes a program (exec?) . this program then requires a filename as input. how do i give it this input in the script so the program will be complete run and close by the script. e.g. exec prog.exe program then asks for filename "enter filename:"... (1 Reply)
Discussion started by: tuathan
1 Replies

7. Programming

Python program faster than C++ program.

I wrote a simple program that generates a random word 10,000,000 times. I wrote it in python, then in C++ and compared the two completion times. The python script was faster! Is that normal? Why would the python script be faster? I was under the impression that C++ was faster. What are some of... (2 Replies)
Discussion started by: cbreiny
2 Replies

8. Programming

Calling c program from another c program

Hi All, Probably this is a repeated question. My knowledge in this is limited and i got confused on all those materials i got in google search. We use #include <> to include a predefined library like stdio.h i saw somewhere that #include "" includes a man made module(another C program). IS... (2 Replies)
Discussion started by: jisha
2 Replies

9. Homework & Coursework Questions

Calling compiled C program with Perl program

Long story short: I'm working inside of a Unix SSH under a bash shell. I have to code a C program that generates a random number. Then I have to call the compiled C program with a Perl program to run the C program 20 times and put all the generated random #s into a text file, then print that text... (1 Reply)
Discussion started by: jdkirby
1 Replies

10. Shell Programming and Scripting

Perl program get a response before the program quits

I created a program, so a kid can practice there math on it. It dispenses varies math problems and the kid must input an answer. I also want it to grade the work they have done, but I can't find the best place for it to print out the grade. I have: if ( $response =~ m/^/ ) { $user_wants_to_quit... (1 Reply)
Discussion started by: germany1517
1 Replies
FBB::binary_search(3bobcat)				      Binary search function				       FBB::binary_search(3bobcat)

NAME
FBB::binary_search - Extensions to the STL binary_search function template SYNOPSIS
#include <bobcat/binarysearch> DESCRIPTION
The FBB::binary_search function templates extend the STL binary_search function template returning an iterator to the element found, instead of a bool value informing the caller whether or not the searched for element is present in a provided iterator range. The bool value returned by the STL binary_search function template is often not the kind of information the caller of the function is interested in. Rather, the caller will often want to use binary_search in the way find_if is used: returning an iterator to the found ele- ment or returning the end-iterator if the element was not found. Whereas find_if does not require the elements in the iterator range to be sorted, and thus will use a linear search binary_search may use the sorted nature of the elements to its advantage, using a binary search algorithm requiring 2 log N iterations to locate the searched for element rather than (on average) N/2 iterations. The FBB::binary_search algorithm uses this binary searching process while at the same time allowing its use like find_if. Since the FBB::binary_search function templates use the same number and types of parameters as the stl::binary_search function templates the explicit use of the FBB namespace will often be required in situations where both function templates are made available to the com- piler. NAMESPACE
FBB All constructors, members, operators and manipulators, mentioned in this man-page, are defined in the namespace FBB. INHERITS FROM
- OVERLOADED FUNCTIONS
In the following description several template type parameters are used. They are: o Iterator represents an iterator type; o Type represents a value of the type to which Iterator points. o Comparator represents a comparator function or class type object which was used to sort the elements to which the Iterator range refer; o Iterator binary_search(Iterator begin, Iterator end, Type const &value): Using a binary search algorithm value is searched for in the range of elements referred to by the provided iterator range. If the value is found an iterator pointing to this value is returned, otherwise end is returned. The elements in the range must have been sorted by the Type::operator<() function. o Iterator binary_search(Iterator begin, Iterator end, Type const &value, Comparator comparator): Using a binary search algorithm value is searched for in the range of elements referred to by the provided iterator range. If the value is found an iterator pointing to this value is returned, otherwise end is returned. The elements and the provided value are compared using comparator(*iterator, value) calls, where *iterator refers to an object in the provided iterator range. The elements in the range must have been sorted by the Comparator function or function object. EXAMPLES
#include <iostream> #include <string> #include "../binarysearch" using namespace std; using namespace FBB; string words[] = { "eight", // alphabetically sorted number-names "five", "four", "nine", "one", "seven", "six", "ten", "three", "two" }; class Comparator { public: bool operator()(string const &left, string const &right) const; }; inline bool Comparator::operator()(string const &left, string const &right) const { return left < right; } bool compFun(string const &left, string const &right) { return left < right; } int main() { string *ret = binary_search(words, words + 10, "five"); if (ret != words + 10) cout << "five is at offset " << (ret - words) << endl; ret = binary_search(words, words + 10, "grandpa"); if (ret == words + 10) cout << "grandpa is not the name of a number "; ret = binary_search(words, words + 10, "five", Comparator()); if (ret != words + 10) cout << "five is at offset " << (ret - words) << endl; ret = binary_search(words, words + 10, "grandpa", compFun); // or use: Comparator() if (ret == words + 10) cout << "grandpa is not the name of a number "; return 0; } FILES
bobcat/binarysearch - defines the template functions SEE ALSO
bobcat(7) BUGS
None reported. DISTRIBUTION FILES
o bobcat_3.01.00-x.dsc: detached signature; o bobcat_3.01.00-x.tar.gz: source archive; o bobcat_3.01.00-x_i386.changes: change log; o libbobcat1_3.01.00-x_*.deb: debian package holding the libraries; o libbobcat1-dev_3.01.00-x_*.deb: debian package holding the libraries, headers and manual pages; o http://sourceforge.net/projects/bobcat: public archive location; BOBCAT
Bobcat is an acronym of `Brokken's Own Base Classes And Templates'. COPYRIGHT
This is free software, distributed under the terms of the GNU General Public License (GPL). AUTHOR
Frank B. Brokken (f.b.brokken@rug.nl). libbobcat1-dev_3.01.00-x.tar.gz 2005-2012 FBB::binary_search(3bobcat)
All times are GMT -4. The time now is 09:00 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy