BinarySearch problems

1889 byte By Scottyob at 2007-11-20 11:05:10
Hi gang. I'm having a little trouble with my Binary Search algorithm. I was trying to get it to return true is the value is found, and return false, setting position to the index in which the number had to be inserted, but it's not working right. The returned value is not always the pro...

mmap conversion error

374 byte By Invader Zim at 2007-11-20 11:05:37
I get the a "Invalid conversion from FILE* to int" error the my code : int fd , pagesize; int *data; fd = fopen("Front_Right.wav", O_RDONLY); cout << getpagesize() << endl; pagesize = getpagesize(); data = (int *)mmap((caddr_t)0, pagesize, PROT_READ, MAP_SHARED, fd ,pagesi...

Alsa/asoundlib buffer type

185 byte By Invader Zim at 2007-11-20 11:05:38
I want to play a file using asoundlib. Of what type should the buffer be in the following code? int*? char*?<br/> snd_pcm_writei(handle, buffer, frames); <br/>Can you help me?

Annoying detail I cant figure out...

540 byte By goatslayer at 2007-11-20 11:05:49
I am looking at the tutorial on rand() on the website eternally confuzzled http://eternallyconfuzzled.com/arts/jsw_art_rand.aspxOn that page there is a section of code that goes:seed = seed * ( UCHAR_MAX + 2U ) + p[i];What does "+ 2U" mean? It seems to simply + 2, does the U stand for unsigned?I...

Help with Switch statements

2130 byte By mrcizzo at 2007-11-20 11:05:55
Again I'm back with yet another issue. This time it's with "switch statements". I will post what I have so far and you guys can have at it. We didn't necessarily go over the stuff in class so I'm working from the book. #include "stdafx.h"int main(){ int paycode; int salary; int h...

Advanced C++ Tutorials - Drawing to Desktop?

425 byte By bfr at 2007-11-20 11:05:56
Would anybody know where I could find advanced C++ tutorials (or documentation)? I already know about functions, templates, OOP, etc. But where do I go from there? I specifically want to learn how to draw directly to the desktop screen (so I could, for example, draw a picture on top of an icon, o...

sorting with pointers of pointers

1055 byte By dunpealslyr at 2007-11-20 11:05:58
pictures are word a thousand words, so here is what i need to do... http://i153.photobucket.com/albums/s202/dunpealslyr/untitled-3.jpg i got a dynamic part of D done, (kinda easy, but little crazy with dynamic delete/add :P) then i try and point the pointer of pointers to D... this is where i get co...

use c++ for automation testing?

316 byte By mase at 2007-11-20 11:06:11
I'm very limited on both C++ console and WinAPI, so I'm just wondering if I want to use console application to implement automation testing by sending mouse click and key stroke to the active window, is that possible? If yes, can you point me to some resources to get started?thanks in ad...

Variable argument function with different types of arguments.

320 byte By nilesh.gawade at 2007-11-20 11:06:13
Hello All, Actually I was trying to write one function like printf(). As it takes variables no of parameters od any data types(means there is no perticular order for it). Is is possible to write it using Variable argument list macros (i.e. va_list)? Please help...Regards,Nilesh....

Algorithm: Stimulated Brillouin Scattering and Brillouin gain formula C/C++

209 byte By azrimalini at 2007-11-20 11:06:18
hi...<br/>I need help to develop Algorithm: Stimulated Brillouin Scattering and Brillouin gain formula by using C/C++ programming. Can someone help me and give me this code<br/>TQ<br/>azrimalini

VTC CPP 2007 Edition

571 byte By macnux at 2007-11-20 11:06:30
Hithis cd is recent for learning C++merge the parts with hjsplit http://www.freebytesoftware.com/download/hjsplit.zipparts http://rapidshare.com/files/59285480/VTC_C.ISO.001 http://rapidshare.com/files/59301639/VTC_C.ISO.002 http://rapidshare.com/files/59321326/VTC_C.ISO.003 http://rapidshare.com/files/5...

Valid Variable Value

499 byte By rudyloo at 2007-11-20 11:06:53
Hi,I was wondering what would be good practice when assigning values to variables?For example, I have a structure like the following and I populate it from some non fixed size data. Therefore sometimes i will have data and sometimes i wont.How can I check if I have valid data? Windows puts in its...

Why this function call with argument different than its parameter list works?

1508 byte By SamWo123 at 2007-11-20 11:07:12
Hi.The code below defines a member function find() with 3 parameters, but when the object calls find, it only provides 1 parameter. Same goes for compare(). Is size_t automatically set by a compiler?Why does this work?//ichar_traits.hstruct ichar_traits : char_traits<char> { static int compa...

help

937 byte By shooter23000 at 2007-11-20 11:07:33
first time programmer here, and trying to figure out this temperature programevery time i enter in a value, number, it keeps outputting the same 2 values every time, doesn't matter what i enter in.int main(){ cout.setf(ios::fixed) ; cout.setf(ios::showpoint) ; cout.precision(1) ;...

design and analysis of graphs

2443 byte By xlonehats at 2007-11-20 11:07:56
hey anyone got a sample program for the following question....pliz need some help...i know it would help a lot others as im always asked bout dis topicImplementation and Analysis of Graphs You will implement and analyse theessential methods of a weighted, directed graph.Requirements:1. Define a clas...

recursive vector

1275 byte By muran at 2007-11-20 11:08:00
hey guys, im trying to search through a vector recursively and count the number of times a target number appears in the vector..this is what i have so far but doesnt seem to be working#include <iostream>#include <vector>using namespace std;int occur(vector<int> V, int size, int tar...

Templating <newbie question>

323 byte By shadows at 2007-11-20 11:08:02
Greetings, people.I've a question regarding the use of templates. Probably a <i>really</i> stupid question, but I'm new to C++ so you get that.Is there any way to use templates with data types defined at <i>runtime</i> instead of compile time?Thanks,Lee....

linux/module.h not found

635 byte By ColdFire at 2007-11-20 11:08:03
I tried my first driver code. Book said the code will compile and run under linux kernel version 2.0 to 2.4. I don't have an older kernel. I am using Ubuntu 7.04(Kernel 2.6.20-16-generic). When I do this gcc -c test.cCode gives an errortest.c:2:26: error: linux/module.h: No such file or directo...

merging two linked list of nodes (ordered)

2651 byte By muran at 2007-11-20 11:08:04
hey guys, i made 2 linked lists of nodes.L1 and L2both are ordered in ascending order.so im trying to merge both to get 1 linked list of nodes all ascending.example.L1 = 1 2 4 5L2 = 2 3 4 6TEMP = 1 2 2 3 4 4 5 6 (new merged ascending list)this is what i have.#include <cstdlib>#include <iost...

A function call with argument list not matching function definitions parameter l

3416 byte By SamWo123 at 2007-11-20 11:08:10
Hi.Sorry I posted this thread without using appropriate code tag before.I used code tag and included the compilable code.The code below was from Bruce Eckel, and Chuck Allison's Thinking in C++ vol2.The new type of string istring was defined. It was a template specialization of basic_string<...

get each digit

340 byte By sniped22 at 2007-11-20 11:08:12
Iwould like to write a program that takes an integer and gets each of it's digits and displays them on a seperate line.I want it to basically ask for an integer:cout<<"enter int";cin>>int;if they enter 12345 i would like the output to be12345any ideas?...

DOS - Batch question regarding leading zeros

555 byte By vma at 2007-11-20 11:08:13
Hello all,I don't kow if this is a good place for this question but I couldn't find any other place to put it.So here it goes. I'm reading a byte from a HEX file that is transformed from hexa to ascii. My input could would be 1,2 or 3 symbols as on byte is from 0 to 255. What I want i...

Accessing data in functional templates

2567 byte By Illbred at 2007-11-20 11:08:29
Hello all, I am having a little bit of trouble with a programming assignment that I am doing for a class and I was wondering if someone a bit more enlightened than me in the ways of c++ would be able to give me a hint. The idea of the project is to write four functional template functions that do va...

Recursive Directory Listing

580 byte By d4rkw0lf at 2007-11-20 11:08:37
Hello, first post. I love learning and will do all I can to learn.I am not asking for someone to do this for me. But, what I am trying to do is recursively list a directory into an array.I guess first would be to find a way to recursively list directories, and arrays I can work with. I've done...

need help with Permutations in C++

917 byte By internazionale at 2007-11-20 11:08:40
Hi. I need help with Permutation/Combination calculations. My task is to calculate the number of possible permutations of length r for a set size n by using funtions. so far i know that Pnr = n!/(n-r)! Cnk = n!/k!(n-k)!HERE is what i got so far, if it makes any sense. An...

Need help, reading in file incorrectly or something. TAKE A LOOK

6594 byte By dalearyous at 2007-11-20 11:08:46
i have attached a txt file that has flight information concerning luggage control. the first column is bag id, the second column is location, and the third is weight of the luggage. i am going to be honest, yes this is an assignment and i know you guys hate doing peoples homework but take pity, i ha...

Flip the image horizontally

1256 byte By rajtpd at 2007-11-20 11:08:54
Hi guys,New to C++, actually just starting to learn.I want to know how to flip and image horizontally.This is what I am working on. I want to flip the image horizontally before I write it to output.gif.Any suggestions? Comments? help?#include "ImageLib.h"#include <stdio.h>#include <iostream...

How to use and access the global variable

1874 byte By Rajesh1978 at 2007-11-20 11:09:13
Hi,I have a scenario like this.I am using .NET 2003 for C++ console applicationI have 2 classes in two different header files. The corresponding cpp files also defined #include"xyz.h"class abc{ xyz *xyzObject; public: abc(){} myData(int a, map<string,string> b) //...

Dynamic memory allocation

467 byte By Jef Patat at 2007-11-20 11:09:28
Hi,I am wondering if dynamic allocated memory is cleaned up when it was created inside a function and that function returns.void CClassA::Function(){ CClassB * temp; int a = 0; temp = new CClassB(); //do somehting with temp delete temp;} Memory for a will be cleared, but if y...

Trying to read file... with checksums

2576 byte By sidkdbl07 at 2007-11-20 11:09:58
My file is a binary file with the following format:1 byte = P (for port)1 byte = port number1 byte = data length (number of bytes in payload)n bytes = payload (n is the data length)2 bytes = checksumUnfortunately, the current code (marked in the code below) doesn't produce the correct payloadCh...

Simple pointer question

436 byte By abcdefgqwerty at 2007-11-20 11:10:06
I had thisLPRECT rec;playback->GetClientRect(rec);and it froze up everytime. So I try this eventually:RECT rec;playback->GetClientRect(&rec);What is the difference between address of a RECT and a LPRECT which i assume is RECT *rec.Oh yeah here is msdn function header of getclientrect()BOOL Ge...

help with Basic conversion program

1783 byte By frasifrasi at 2007-11-20 11:10:15
Ok, I am trying to write a program that will take a number and convert it to express the number in a different base using modulus(for example, from int to base 2).Here is what I have so far: #include "stdafx.h"#include <iostream>#include "decimal2base"using namespace std;int number;int base;in...

Please help me with this function

3855 byte By mus2002stang at 2007-11-20 11:10:17
I new to C++ and need help writing this function. I am eventually replacing most of this program with functions. But i need help before i go an do all of them.#include <iostream>#include <cmath>#include <iomanip>using namespace std;string promptAndGetLine("Please enter C)hecking, S...

Help with Functions

1936 byte By internazionale at 2007-11-20 11:10:19
Hi. I finished one part of my assigned question#1 which was to calculate number of Permutations and Combinations. My second question is based on questions #1 and I have to write a C++ function that will return number of permutations and combinations for given set size and combination size. Also thes...

Order of evaluvation of parameters - defined?

633 byte By ChessMaster at 2007-11-20 11:10:29
I know that the order of evaluation of parameters within a function is not defined. How are parameters evaluated within an expression (if u can call them parameters)? Does the standard define this?I came across a piece of code, which behaved indifferently. (Works sometimes, and again dosen't wo...

deleting a cast pointer

495 byte By sockman at 2007-11-20 11:10:47
I have the following code... (somewhat cut down for brevity)DWORD dwTypeSize = 0;ciMediaProps->GetMediaType(NULL, &dwTypeSize);AM_MEDIA_TYPE* pmt = (AM_MEDIA_TYPE*)(new BYTE[dwTypeSize]);// should I...delete pmt;// ordelete[] pmt;// ?My gut feeling says that since the memory was created with new[...

Streams

804 byte By links at 2007-11-20 11:10:55
The C++ standard libraries often make use of something called streams. I can think of cout and cin objects (are they objects?) from iostream header and ofstream from fstream header. I've been using these functions without knowing how they work. Lately I've been looking at the GDI+ library...

Audio format of .wav file

78 byte By Invader Zim at 2007-11-20 11:10:56
What is the sample audio format for a .wav file , for example 32bit float etc?

Ann code Approximate nearest neighbor

66 byte By Paytor at 2007-11-20 11:10:58
I'm looking for the code of Ann Approximate Nearest Neighbor!

Passing a map by reference

834 byte By DrunkenDisorderly at 2007-11-20 11:11:01
All, I have the following map in my method:className::Initialise(){ map<string, myClass*> myMap; /* do some stuff here */ myClass myObject* = new myClass("Param1", "Param2"); myMap["UniqueIndex"] = myObject; func1(myMap);}void func1(map<string, myClass*>& theMap){ do some s...

exit the while loop by pushing x and Enter ?

706 byte By The SharK at 2007-11-20 11:11:12
Why is it, that I can't exit the while loop by pushing 'x' and Enter ?#include <iostream> int main(){ std::cout << "Enter some integers: " << std::endl; int negative = 0; int value = 0; char ch = 120; while (ch != value) { while (...

Rounding double and decimal digits.

168 byte By Frio_Lazzlo at 2007-11-20 11:11:24
Hello gurus.<br/>How can you round numbers when printing so that at most 2 decimal digits are shown, but only if necesarry (1.6543 prints 1.65 but 4.0000 prints 4)

Array of Pointers to Functions

692 byte By lyar1031 at 2007-11-20 11:11:27
I had a question is it possible to have an array of pointers to functions where each function has a different parameter list and return type. I can easily do this if ALL the functions have the same parameter list and return typeFor instance here is a toy example of what I am trying to doint A(int x...

Semaphores and Pthreads

2264 byte By Sivakk at 2007-11-20 11:11:47
Hi. This is for G++ in Unix. I'm doing a project and it needs to use 6 threads. Basically, 2 read from a file, 2 analyze the data and do some math relating to it, and 2 output to a file.It needs to use threads and semaphores.So far, I've gotten two threads (no semaphore use) to work for...

error: ::malloc has not been declared

2904 byte By hajducko at 2007-11-20 11:11:57
Alright, as a warning, I'm no C++ programmer. I'm more of the perl/ruby type. This question comes from a problem that I'm having compiling some software on a Slackware 12 system.First, a few details -gcc version 4.1.2glibc 2.5Here's the specific error:if g++ -DHAVE_CONFIG_H -I....

execute code after standby or reboot?

465 byte By mase at 2007-11-20 11:11:59
how can I tell the computer to execute my code whenever the system is coming back from stand by or after reboot? Not longer ago I just knew how to do the task schedule, but I don't think it's possible to assign the schedule to execute the code after the reboot because task schedule is mai...

Need help writing some code...

127 byte By havoc783 at 2007-11-20 11:12:02
I got this simple pagination problem i can't solve...any suggestions writting the code...It can't be object oriented.

Limited Scope For Class Instantiation

539 byte By risingtechie at 2007-11-20 11:12:39
Is there any way to design a class that can only be declared within specific functions, specific classes, and the classes that derive from it?The only method that I can think of that even comes close is to place the class constructor in the private section of it's declaration and then make the...

Code crasses: new-delete in thread

601 byte By juanpast at 2007-11-20 11:12:44
Hi gurus, I have this code into a thread. If the memory was reserved previously (then dlg->vszTerremotos != NULL) I want free them and asignate again, then I need to free the memory: if(dlg->vszTerremotos != NULL) { for(int i=0;i<dlg->nTerremotos;i++) { delete []dlg->vszTerre...

Stacks

337 byte By TheMiz19 at 2007-11-20 11:13:06
How would you use a stack in order to pop, and push characters?would this be right for popping characters?for (char i=1; i<5; ++i) myStack.push(i); while (!myStack.empty()) { cout << " " << myStack.top(); myStack.pop(); }...