Trying to implement a list and keep getting segmentation fault

2949 byte By Ekranoplan at 2007-11-20 11:31:17
For a homework assignment, I need to create a list that implements an associative array. The associative array is to be used in a program to keep track of the words and the amount of times they appear in a string. What I have here is just the Class that implements the array, and a small program to...

compiling multiple includes to 1 file

666 byte By Red Squirrel at 2007-11-20 11:31:20
a typical app will have some includes and stuff going to other files. Is there a program out there that will parse these and make a single file with all the code from includes? I want to be able to do this when I distribute source code on say, a forum. Easier then having to include all files. In...

compute frequency

1158 byte By xlonehats at 2007-11-20 11:31:22
hey guys....im trying to solve a problemComputeCharacterFrequency: reads a text message from a text file (the path and filenameshould be entered by the user at run-time e.g. c:\\input.txt) and computes thefrequency of each character used in the message. This function should then display eachcharacte...

beginner and loops

899 byte By shooter23000 at 2007-11-20 11:31:23
hey guys i just started programming, and am having a hard time trying to figure out loops and how they work in general.they gave us this example:What multiples are we adding? 5The sum of multiples of 5 less than 100 are: 950and the loop for it iscout << "What multiples are we adding? "; int...

Linker Error With BCC32

1309 byte By utsavgupta at 2007-11-20 11:31:24
Hi,I wrote a simple assembly program and i am trying to interface it with C.I have compiled my c++ driver with BCC32 and the assembly program with NASM (32 bit). Now while linking i am getting this error message:Unresolved external 'asm_main()' referenced from C:\driver.objWell here is my...

delete this pointer

382 byte By George2 at 2007-11-20 11:31:32
Hello everyone,Just interested to learn how C++ implements delete this statement internally. From logical point of view, I can not imagine how to implement a component which destroy itself.What makes me confused is the component is relying on itself even in the process of destroy, how could it destr...

Cant cout vector<string>

681 byte By Peithon at 2007-11-20 11:31:35
Hi,I'm trying to create a vector of strings and print the contents using an iterator but I'm gettingan error with my very first string.Can anyone help?#include <iostream>#include <cstring>#include <vector>using namespace std;int main(){ char* temp1 = NULL; vector<strin...

cany anyone simplify this code? (multiplying the product of two vectors)

709 byte By lab1 at 2007-11-20 11:31:47
Hello all,I have the following code which computes all combinations of products & convert to vector form. Bin1, Bin2, Bin3, nonZero1, nonZero2 and masses are all of type: vector<float> for(size_t i=0; i<Bin1.size(); i++) { for(size_t j = 0; j < Bin2.size(); j++) {...

removing comments in a c program

148 byte By rohit83.ken at 2007-11-20 11:32:00
i want to write a program that takes a file having comments and removes<br/> the comments and prints the c source code file into the other file

help me with array

328 byte By akeybreakerz at 2007-11-20 11:32:02
can somebody give me the coding solution for this problem? plizzzzWrite a program which will sort the numbers in the following array.Array [ ] = { 35,-2,-400,3,7,26,48,102,8,11,99,69,70,101,77}From the lowest (array[0]) to the highest value (array[14]) and print the result from highest to lowest....

Few questions for which i have no answer

512 byte By dany123 at 2007-11-20 11:32:10
i m really doubtfull abt these .......these are in c/c++ 1.Why it is necessary to allocate memory when i can do all without allocating memory from pointers just pointing it.for eg: int *str="hello";or allocating memory to str first then allocate it will do same work then why it is neccessary to allo...

removing contents of the type // and /*

389 byte By rohit83.ken at 2007-11-20 11:32:13
please help me in writing the code that takes a c or c++ file and deletes the comments and prints the output to other filetotally 3 files r involvedone removes the comments other is the program having commentsother is output printed without any comments containing c or c++ codeprethanks to the helpe...

wxWidgets

231 byte By gamer150 at 2007-11-20 11:32:20
I just downloaded the wxWidgets package for dev-c++ 4.9.9.2. When i create a new project with the wxWindow template and try to compile it, I get an error.<br/> [Linker error] undefined reference to `__cpu_features_init'

struct members problem

3711 byte By John_M_Gough at 2007-11-20 11:32:22
The following structure is for reading variables from a file. the information read is stored in an array. at the bottom of the code i am trying to add the value to the arrays. Im currentley working on the String, the string is read from the file, but i cant write it to the array member Strings[]. th...

strange use of () in c++

961 byte By SamWo123 at 2007-11-20 11:32:23
Hi.I dont understand the role of() in the code below.C<float, int>().f() //template specialization of C, and f is a member of template class Cf() is not static member, why can it be called without having a class object, and what is that() before f() for?ThanksSam W.#include <iostream>usi...

Queue

59 byte By TheMiz19 at 2007-11-20 11:32:33
How would i code, a queue that sorts data from a .txt file?

Exceptions and Destructors

1115 byte By Plasmator at 2007-11-20 11:32:41
A scaled-down version of my code:void Test(){ try { struct TestStruct { TestStruct() { if(/*some check fails*/) throw runtime_error("..."); } ~TestStruct() { //release some resources //should only be called if the constructor finishes successfully (i.e., doesn't thro...

Tell Him Hes Wrong!

787 byte By RaleTheBlade at 2007-11-20 11:32:48
My instructor is insisting on this test that we put "Acme Manufacturing" into a character array named company as if it were a string. He even refers to it as a "string" in the test question, but in the struct, it is specified aschar company[21];Which by all means that I know of cannot accept literal...

I need a hint on how to do this.

364 byte By k0b381 at 2007-11-20 11:32:51
* *** ************ ********draw this figure Using only 2 couts, one for a single space, and one for a single *. You can use as many loops as you needi know you have to use setw to do it...

Global Variables

634 byte By WhoCares357 at 2007-11-20 11:32:57
How is everyone? I'm kinda new to c++ and was trying to make a little text-based rpg game. I created some global variables (strings and integers). When I compiled my product, I had a weird error that said that I never declared the global variables. Wherever I used the global variables in functi...

C++ Primer 4th. Ed. Exercise 1.26 by Lippman

334 byte By The SharK at 2007-11-20 11:33:00
In this exercise, they use code like:sum = sum + newItem;They ask why they didn't use the compound assignment operator ?My problem with this question is - I can't see the difference betweenusing:sum += newItem;orsum = sum + newItem;regards,The SharK...

suggest in correcting this code

3018 byte By rohit83.ken at 2007-11-20 11:33:05
its a program to remove commentsits not working properly//Program to print a file by removing Comments#include<stdio.h>void main(){ FILE *fp; char ch; //clrscr(); fp=fopen("temp.txt","r"); while(1) { ch=fgetc(fp);...

thread stopped? help me..

7601 byte By akeybreakerz at 2007-11-20 11:33:11
ok this is my coding and im using the borland c++ compileredit: sori for not usin the tag codes, i still don't know whats wrong, never get a thread error before..#include<iostream>#include<conio.h>#include<iomanip.h>void getProblem();void get2Pt();float SlopeInteptFrom2Pt(floa...

[RESOLVED] Design question about base classes which cant be instantiated.

1664 byte By DaMagic at 2007-11-20 11:33:12
Hello, I have a question about the design of base classes from which a caller must not create an instance. My english is not very well but I try to explain in detail.I have a base class for which creating instances from is forbidden but I do not have any pure virtual functions for this class. So, ho...

inline function

170 byte By ajaysharma2007 at 2007-11-20 11:33:16
-> what is inline function?<br/>-> whether we can use return statements in inline or not? and why?<br/>-> why we can not use loops or switch statemant in inline?

logic problems

942 byte By rohit83.ken at 2007-11-20 11:33:18
//removes comments from the file and prints to the other file#include<stdio.h>void main(int argc,char *argv[]){ FILE *in,*out; char ch1,ch2; int f=0; in=fopen(argv[1],"r"); out=fopen(argv[2],"w"); while(!feof(in)) { ch1=getc(in); if(ch1=='/') { if((ch2=getc(in))=='...

Command line arguments problem

1651 byte By standmatt at 2007-11-20 11:33:23
Hey everyone, I'm working on a project for my Computer Science class and I'm having a problem taking in these command line arguments.I get the error bash-3.00$ g++ water.cppwater.cpp: In function `int main(int, char**)':water.cpp:28: error: invalid conversion from `Config*' to `...

floating points

157 byte By akeybreakerz at 2007-11-20 11:33:25
suppose the value after a calculation is 1.666666666667.<br/>how can i get the value of only 1.66?<br/>i want to assign that (1.66) as a value in a variable.

Get Character Values From String

464 byte By Capnrawr at 2007-11-20 11:33:27
Hi, here's my problem. I'm reading in 5 words from a text file by using an array of pointers to characters.char **input;I then allocate memory for each component of input and read in the files.Now, how would I get the individual values for each character in one word?Ex. input[0] = "apple"H...

Objects members in Stack vs. Heap

770 byte By thekemal at 2007-11-20 11:33:30
I know that the allocation and deallocation of the objects in stack are faster than the heap. I am not sure about the changing or getting the object's members. Which one is faster? For example:class myClass{public:myClass(int a, int b){var1 = a;var2 = b;}int var1;int var2;};int main(void){myCla...

weird error

2673 byte By nerdykid at 2007-11-20 11:33:34
i have some code to generate a random number between 1 and 100 that the user is supposed to guess, but for some reason, its always 31. i tried to implement it in another program, and it worked perfectly fine, so i have no clue wut is rong with ithere is the entire code, becuase there is probably som...

Help with exponents loop, not allowed to use pow() library

838 byte By zalery at 2007-11-20 11:33:41
so i'm trying to set up this exponents loop, keep in mind this is my first year in computer science so my knowledge of script is somewhat minimal. basically this assignment (or at least part of it) tells us to have the user enter 2 numbers, (left and right) and to output the correct answer usin...

A beginner needing an explanation on a few concepts of c++

479 byte By SilverLining at 2007-11-20 11:33:42
Hey, I'm new to c++ and these forums and was wondering if someone could explain to me what classes, constructors, and templates are, what they do, and how they work? These concepts really confuse me out of all the concepts I've learned about so far in c++. Short, simple examples would be h...

Storing a Pattern into an Array

618 byte By veronicak5678 at 2007-11-20 11:33:44
Hello-My assignment is to come up with an algorithm to display a Christmas tree, then store it in a two dimensional array and display it with loops. I came up with the pattern, but don't understand how to put it in an array. Here's my code:Code:void pattern (){ int i, j; cout <&...

trim heading and trailing space

311 byte By George2 at 2007-11-20 11:33:50
Hello everyone,I think in built-in C/C++ functions, there is no direct function call to trim heading and trailing space characters, right? So, we have to implement it manually by iterating the string to check character one by one.Support not using MFC.thanks in advance,George...

references to functions within a class

1315 byte By Chrip at 2007-11-20 11:33:55
Hey,How can I get this one work?There is a class which gets a function f as an argument. This function is combined with other ones to a new function diff. So far it's fine.Now I want to pass this new function as a reference for further usage. I just can't get around this error the compiler...

derived class can not access base class protected member?

685 byte By George2 at 2007-11-20 11:34:03
Hello everyone,I met with a strange issue that derived class function can not access base class's protected member. Do you know why?Here is the error message and code.error C2248: 'base::~base' : cannot access protected member declared in class 'base'class base{protected: ~b...

structures and memory blocks

636 byte By c94wjpn at 2007-11-20 11:34:04
hi folksCan you treat struct-instances as memory blocks and vica-versa? assuming you have no virtual functions or anything.Here is some code:struct A{ float m_f; int m_n1; int m_n2;};A aa;aa.m_n2 = 5;BYTE* p = (cast)&aa;assert(*(p+11)==5);/// or even this:BYTE* p = new BYTE[12];memset(p, 1,...

Why isnt this working?

2294 byte By axehero at 2007-11-20 11:34:10
So I am trying to use the rand function to create a random number in between a set of numbers, yet it is not working for whatever reason, and I can't figure it out. Some lines are omitted to save space. I am using Dev-C++. Heres the code:#include <iostream>#include <cstdlib>#includ...

table

873 byte By shooter23000 at 2007-11-20 11:34:22
ok i'm trying to build this table and have this so far#include <iostream>using namespace std;int main(){ int me; int row; int column; int sum = 0; for (row =1; row <= 12; row++) for (column = 1; column <= 12; column++) { cout << row * column;...

Array Help

615 byte By helloworldc++ at 2007-11-20 11:34:26
Hi,I need some help on how to get information from another data file and loading displaying it.Data File===================01 45 5.6 3.5 6.502 34 5.2 2.4 5.503 65 9.3 2.5 6.5What I need to do is get the first column as well as second column and print them, but I also need the 3rd, 4th, and 5th colum...

Read input from a file and loop it

2098 byte By lifeis2evil at 2007-11-20 11:34:33
I really need help with this code :( I am really stuck. The part i am stuck in is where I have to make it read the input file and loop it so that it reads each line. if its a m (male) or if its a f (female) depending on what the person picks and then for it to calculate the average if which ever the...

How to use Java class/method in C++ class(urgent-Pls respond)

228 byte By digvijayrai at 2007-11-20 11:34:35
Hi Friends,<br/>I want to send string parameter from C++ class to a Java method and print the response in C++ program.Could you tell me step by step.It will be great if you provide some sample example.<br/>Thanks in advance

Need code (turbo c++) to display time all through the program on its own.

699 byte By Mr Virtual at 2007-11-20 11:34:59
Hello everyoneJust joined. I am working in turbo C++ 3.01 . I have seen at many places, like banks and shopping centres, that their screens always show time (like in Windows). I am making a school project and I thought of doing this, but haven't got any idea how to. Please explain to me along w...

pretty sure im doing this right, but compiler doesnt lie

660 byte By nippysaurus at 2007-11-20 11:35:09
I have not done c++ for a while now but need to use again.I have some simple code below ...class ClassOne{ private: public: ClassOne(ClassTwo* hello) { // }};class ClassTwo{ private: public: ClassTwo(ClassTwo* hello) { // }};Why this will not compile is beyond me! I spent about an hour loo...

source of image on c++ program

412 byte By Rooting at 2007-11-20 11:35:12
hi friends!!...i'm now writing about another question that in google I didn't findanswer..I have a image, and i would make a programm to see the code of it.how can i open the image in source code as I open it whith a notepad.??..and if i would search on the source of image 1 word, how can...

Virtual inheritance

289 byte By George2 at 2007-11-20 11:35:13
Hello everyone,<br/>I have learned public/private/protected inheritance, but what is virtual inheritance? Here is the sample,<br/>class Usable : public virtual Usable_lock <br/> http://www.research.att.com/~bs/bs_faq2.html#no-derivation<br/>thanks in advance,<br/>George

loosing the data saved into an object

3585 byte By jewel87 at 2007-11-20 11:35:31
Hi,I have a problem with saving data to an object and displaying it. I am calling two functions, one to enter the data into object, and second to display that object data. When i try to debug the program using breakpoints, i see that the data is saved into the object attribute values, but when the d...

Why the destructor is called?

2187 byte By scherzo at 2007-11-20 11:35:41
Hello everyone!I'm coding an application and I don't understand why it isn't working. I've written a simple example to show you my problem:___________________________________________________________#include <iostream>using std::cout;class test { friend test operator+(test&,...

MSVCRTD.DLL Access Violation

486 byte By rudyloo at 2007-11-20 11:35:45
Hi,I have a VC6++ MFC application and it is giving some problems in debug mode when running on my laptop.I run the application and once i exit, i get the following error:Unhandled exception in Myapp.exe (MSVCRT.DLL): 0xC0000005: Access Violation.I cant figure out why I am having this problem. I hav...