General C++ Programming - November 2009

weirdest code ever
 
this is an overloading function of the plus operator, weird thing is that when I make my vector larger and then print the corresponding elements in the vector i...
[no replies]
Strange command line argument behaviour
 
I have this code which is supposed to convert an URL to the form in which it is used in a DNS request: #include <stdio.h> #include <string.h> int main...
[3 replies] Last: Thanks helios, can't believe I didn't spot that after staring at my sc... (by Chewbob)
infix to postfix
 
I need help with a program for converting infix to postfix. heres my main program: #define Sentinel ‘=’ #define SIZE 15 enum ItemIDTYPE {INVALIDCHAR,...
[10 replies] Last: ok,i have other questions that have nothing to do with errors.im havin... (by kakashi316)
string arrays in a for loop?
 
Forgive me if my terminology is off. I'm using visual studio 2008 c++. I'm doing a movie rental project where I have to create a list of movies (listing name,...
[4 replies] Last: [quote=us3rn4m3]i will code it for you to make your homework done. ... (by firedraco)
Function problem
 
My program is supposed to take numbers from the user and should only stop when 0 is entered. My should then determine the amount of even and odd numbers entered...
[1 reply] : [code firstline=19]while (!(num=0)) should be while ( !(num==0) ) ... (by Bazzy)
string to two's complement (1,2)
 
If I have a string "52" is there a way to convert this to it's two's complement value(in bits), which is 00110100 WITHOUT converting 52 to an int first... I ...
[35 replies] Last: Flip bits and increment. You should already know all this. (by helios)
Sorting a Linked List
 
Hi I'm trying to sort a linked list I created using a function but I have no idea how to sort it. Can anyone help me? Here's my Code: #ifndef _ASSIGNMEN...
[2 replies] Last: your bubble sort thing works if you preserve the starting point. do... (by herbert1910)
by tene
Binary Search in Linked List
 
An interviewer asked me to search nth node in a linked list. I gave him the logic of linear search, iterating till the nth node. He wants a faster approach. ...
[4 replies] Last: Thats what I am also wondering.. I think its not possible to reach an... (by tene)
n-th Fibonacci number in O(logn)
 
This is recursive function to compute nth Fibonacci number and is of O(n) time: int Fibonacci(int n) { if (n == 0 || n == 1) return n; el...
[7 replies] Last: I agree that a lookup table can be used with any solution. I just s... (by jsmith)
pass mp3 file through program
 
The attached code takes and mp3 file and converts it from 16bits to 8eight bits as well sends the PCM through the serial port. I was able to compile it in MSVC ...
[11 replies] Last: A * between 'const char' and the identifier? (by helios)
getline() & fstream behavior
 
I'm testing fin functions and I came across this. Does anyone have any idea why getline fails to extract the char ? (i.e.'This is a sentence!') I suspect th...
[4 replies] Last: I removed an extra fin >> stringTwo statement and kept the ignore call... (by Discere Faciendo)
Question
 
I need a short example of a program with: Data structures Dynamic arrays enumerations unions pointer arithmetic sorting File I/O
[3 replies] Last: Wait a second; I'm not going to do your homework for you? Haha... (by mcleano)
User Functions
 
Finding difficulty creating a user function program: Given: tanh (x) = 1-2e^(-2x) + 2e^(-4x) - 2e^(-6x) + 2e^(-8x) -2e^(-10x) + ... cos(x) = 1-x...
[1 reply] : can anyone help me with writing this code: Trying to write a larger p... (by sl02ggp)
Using Complex Numbers for Circles and Right Triangles.
 
Hello People...HAPPY BELATED THANKSGIVING...I'm having problems trying to get this Complex program to do certain functions...Here is my problems... * Suppose t...
[3 replies] Last: Four different complex numbers a,b,c,d lie on a cirlce if and only i... (by tition)
by chrivo
Library for interactive command line interface?
 
Hi, I'm looking for a way to control my program interactively through a command line interface. Similar to controlling linux through the shell or python thro...
[12 replies] Last: Command line input is a stream, parsing input isn't difficult. Maybe ... (by Bazzy)
Writing a 2d vector of objects to a file?
 
Hello everyone, I have a 2d vector of objects that I need to write to a file and then read back from it later on. Can anyone please provide me information on...
[1 reply] : Overload the << and >> operators for your class, then iterate through ... (by Bazzy)
by Zendet
Loop
 
hello, i have a program that i need to repeat a section of it so many times, the amount of times it needs to repeat is what the user enters at the start. ...
[15 replies] Last: inb4 ............................................________ ............ (by bluezor)
Encryption/Decryption program not working
 
Hi, I tried to make an encrypting/decrypting program, and it isn't working as I planned, plus I can't find a solution for my problem. The problem is: Lets ta...
[1 reply] : I guess because in ASCII, 1 - 3 isn't ABC? I suggest checking up a tab... (by bluezor)
Need idea for a while condition
 
Bascially, I have a string called 'fileContent' that contains the text of a file that has been read and I just need the while loop to loop until I've searched t...
[5 replies] Last: Helios: Yes thats correct: std::string createSubString(std::string... (by mcleano)
by Tex
Losing part of char array returning from function by reference
 
The contents of the array are safe within the function, however, upon returning to main the data becomes garbled. section of main: unsigned short tcp_por...
[1 reply] : In the future, please put your code in code tags: [co de] Put you... (by Disch)
November 2009 Pages: 123... 16
  Archived months: [oct2009] [dec2009]

This is an archived page. To post a new message, go to the current page.