6,741 Posted Topics

Member Avatar for arnie6

Use strstr to find the string you want to remove and then copy over it. Someting along these lines: [code] char *p = strstr ( place, arg ); int start = p - place; int end = start + strlen ( arg ); memmove ( place + start, place + …

Member Avatar for Narue
0
113
Member Avatar for compshooter

The easiest way would be to maintain a sorted list as items are entered, then have the list take on queue behavior after all items have been entered. Is this a suitable solution?

Member Avatar for compshooter
0
238
Member Avatar for rafalkw
Member Avatar for Purps

There's no hope for that code. Start over, this time paying close attention to a good C++ reference.

Member Avatar for Narue
0
247
Member Avatar for cap2361

>I want to ensure that the user puts in a name with characters and not use numbers. Why? Numbers would be a valid string, and forcing your players to enter alphabetic characters may be an unnecessary restriction. Especially since it requires more work and code from you, and therefore more …

Member Avatar for Narue
0
312
Member Avatar for jhdobbins

i is an integer, "," is a string. You can't compare them directly. Did you mean: [code] while ( first[i] != ',' ) [/code]

Member Avatar for jhdobbins
0
155
Member Avatar for Acidburn

You need to write an operator<< for BankAccount: [code] class BankAccount { public: //void setAccount(int num, double amount); taken out replaced by constructor BankAccount(int num, double amount); BankAccount(); int getBalance(); int getAccountNumber(); void deposit(double AnAmount); void withdraw(double AnAmount); [COLOR=Blue]friend ostream& operator<< ( ostream& out, const BankAccount& b ) { return …

Member Avatar for Narue
0
139
Member Avatar for JoBe

>what would you do different I wouldn't waste my time performing the calculations manually: [code] #include <ctime> #include <iomanip> #include <iostream> using namespace std; class Time { public: Time ( int hours = 0, int minutes = 0 ) { time_t t = time ( 0 ); data = *localtime …

Member Avatar for Narue
0
646
Member Avatar for Acidburn

You have [b]got[/b] to be kidding! The error says that calArea needs to return a value. The definition of calArea is: [code] double Shape::calArea() { } [/code] How is that confusing? All you need to do is return a value: [code] double Shape::calArea() { return 0; } [/code]

Member Avatar for Narue
0
215
Member Avatar for sinrtb

>1. how can i pause my cout output? or is it possible to do it without calling a system command Ask for input and discard it: [code] cout<<"Press enter to continue."; cin.ignore ( numeric_limits<streamsize>::max(), '\n' ); cin.get(); [/code] The call to cin.ignore() makes sure that there's no unwanted data in …

Member Avatar for Narue
0
129
Member Avatar for sam1

Unless you're the kind of person that enjoys partitioning and installing operating systems, or you REALLY have to have a Linux partition, get a live CD such as Knoppix or Mandrake Move. It's so much easier.

Member Avatar for amos
0
204
Member Avatar for sunandoghosh

>(1) what exactly is programming, Programming consists of designing software, writing instructions in a programming language that execute steps which implement that design, testing the instructions to ensure that they work properly, and fixing any errors that occur. >(2) what exactly programmers do Programmers create software. :) >(3) Is it …

Member Avatar for Narue
0
191
Member Avatar for Rose Aashii

>whole program is correct but at end it is not displaying correct result. Then the whole program is not correct. :rolleyes: >#include<stdio.h> This isn't needed. >main() This is illegal C++. Implicit int is not allowed, so you need to say: [code] int main() [/code] >for(int i=0;i<10;i++) This is not portable …

Member Avatar for Narue
0
228
Member Avatar for Fasola

>1. Why do you need Self-Referential Classes? It's the easiest way to implement non-contiguous data structures. You don't [b]need[/b] them, but they make life easier. >2. ^^^What is a Node, is it just a random name for this Class? [url=http://en.wikipedia.org/wiki/Node_%28computer_science%29]Node[/url] >3. what does the (const Node *) mean in It's …

Member Avatar for Fasola
1
960
Member Avatar for riturajraina

Which system are you compiling on, and which system are you compiling for? The error basically says that the virtual DOS machine is encountering errors with your 16-bit program on a 32-bit system. It could be something you're doing, or something you're not doing that you should be. Though I …

Member Avatar for Narue
0
154
Member Avatar for Bud4java

[code] (int)Math.pow ( 2, b ); // Cast the result of pow to int [/code]

Member Avatar for Bud4java
0
152
Member Avatar for byte_me

>void main() Wrong, main returns int. >gets(vehicle.V_RegNo); Wrong, gets can never be made safe. Use fgets on stdin instead. >fflush(stdin); Wrong, fflush is only defined for output streams. stdin is an input stream. The equivalent correct code is: [code] int ch; while ( ( ch = getchar() ) != EOF …

Member Avatar for byte_me
0
186
Member Avatar for evilsilver

>void loadsave (); It's best to avoid using one function for two wildly different operations. >string convert; I'll assume that string.h defines a string class on your old ass compiler. Otherwise this is a ghastly error. >if (savedplayers >=1) I'd bet my next paycheck that you want to enclose the …

Member Avatar for evilsilver
0
218
Member Avatar for xerxes1986

Make this change and call it good: [code] double AirborneLocation :: distance() [COLOR=Blue]const[/COLOR] { [/code]

Member Avatar for Narue
0
177
Member Avatar for mrlucio79
Member Avatar for atrusmre

>Any ideas what could be causing this? With the amount of information you've given, it could be anything at all.

Member Avatar for Narue
0
140
Member Avatar for mikecoyner

>i would like to use a window for user interface instead of dos console. My first question is "why"? Introducing graphics should be done only after the students have a strong foundation in the core language and standard libraries. Otherwise, they'll find themselves battling C++ as well as whatever graphics …

Member Avatar for Narue
0
212
Member Avatar for s-sriram

[code] user_name = 'user' for i in range ( 1, 100 ): user = user_name + str ( i ) print user else: print 'The loop is done' [/code]

Member Avatar for s-sriram
0
334
Member Avatar for camduthie

Try something more like this: [code] #include <cstdlib> #include <fstream> #include <iostream> #include <string> #include <vector> using namespace std; int main() { cout<<"An empty string or EOF will stop the program"<<endl; for ( ; ; ) { string name; cout<<"Enter a name to search for: "; if ( !getline ( …

Member Avatar for Narue
0
111
Member Avatar for ecua_frap

Most likely you're trying to use a standard template class without including the header. Post the code.

Member Avatar for kc0arf
0
128
Member Avatar for Bud4java
Member Avatar for Bud4java
0
95
Member Avatar for robert_sun

The easiest way to get a truly global variable (accessible across multiple translation units) is to declare it in the common header, and define it in a special translation unit: [code] /* header.h */ #include "defs.h" extern int memory[SIZE]; [/code] [code] /* header.c */ #include "header.h" int memory[SIZE]; [/code] Now …

Member Avatar for Narue
0
131
Member Avatar for grifflyn

>is ArrayList better than Vec It depends on your needs. If you need a synchronized list and it has to be compatible with Java 1.1 then Vector is an option. Otherwise, ArrayList should be preferred, and Collections.synchronizedList will give you synchronization (which ArrayList does not have by default). >how do …

Member Avatar for jwenting
0
161
Member Avatar for skyhawk133

Huh? Did something change? ;) Minor gripe: Your fontage seems a little small, and if it's small for me, a lot of people may have a problem with it.

Member Avatar for Dani
0
313
Member Avatar for cblue

>Alternatively you can use the functions itoa and atoi respectively. itoa isn't a standard function, so it may not be available.

Member Avatar for Narue
0
196
Member Avatar for Mr Violent

>I have tried #include <cstring> That header has nothing to do with MFC. It's a header with functions and types for working with C-style strings (ie. arrays of char terminated with '\0'). Might I suggest the std::string class? It's easier to work with than CString, and also provides conversions to …

Member Avatar for Narue
0
488
Member Avatar for jonnie83

[code] string string1 ("DDRA"); string string2 ("DDRB"); string string3 ("0021"); string string4 ("CLR"); string string5 ("LDAA"); string string6 ("LDAB"); string string7 ("READ"); string string8 ("ABA"); string string9 ("STAA"); string string10 ("END"); [/code] This is a sign you should be using an array. [code] int counter; counter=0; if (string1.find(filename.c_str())) ++counter; if …

Member Avatar for Narue
0
219
Member Avatar for Rose Aashii

I notice a lack of attempt on your part. It seems like you're asking [b]us[/b] to do [B]your[/B] work for you. It doesn't work that way around here. Sorry.

Member Avatar for Narue
0
263
Member Avatar for some one

>what is the problem What are the symptoms? I can point out a lot of stuff that could be considered a "problem", but since we can't read your mind, we don't know which of them you're referring to. Dave also asked you a question and suggested a way to improve …

Member Avatar for Narue
0
208
Member Avatar for some one

What part of it are you having trouble with? And don't say all of it, because I'll stop helping if you act like you want us to give you solutions without any effort on your part.

Member Avatar for some one
0
507
Member Avatar for jonnie83

[code]if (!getline(cin, search)) { count; }[/code] If getline fails, you basically do nothing here. You're reading the value of count (0) and doing nothing with it. [code] { ifstream in("MarkScheme.txt"); if (!in){ cerr<<"Mark Scheme not found"<<endl; return EXIT_FAILURE; } } // End local [/code] This also does practically nothing. Because …

Member Avatar for Narue
0
169
Member Avatar for Sluga

An array is not a modifiable lvalue, so you can't assign to one using the = operator. You need to copy each element from the source array to the destination array individually. This is best done with a loop, but since your array only has two elements, you can do …

Member Avatar for Sluga
0
2K
Member Avatar for Starz20

Throw the whole thing in a loop and break from the loop if the user enters something that isn't valid: [code] #include <stdio.h> #include <stdlib.h> #include <string.h> #define MAXLINE 256 int main(void) { char str[MAXLINE], rev[MAXLINE]; int i, length; for ( ; ; ) { /*-------------------------------------------- * Read string and …

Member Avatar for Narue
0
168
Member Avatar for some one

>ages[b-1]=ages[i]; That's your error. i isn't an index, it's a content value, and the value could very well exceed 999, which is the largest possible index for ages. Change that line to: [code] ages[b-1]=ages[b]; [/code] You probably also want to restructure your code so that it has specific sections for …

Member Avatar for some one
0
116
Member Avatar for nizar4445

[code] #include <algorithm> #include <iostream> #include <iterator> using namespace std; int main() { int a[] = {5,7,4,6,3,8,0,1,9,2}; sort ( a, a + 10 ); copy ( a, a + 10, ostream_iterator<int> ( cout, " " ) ); } [/code] ;)

Member Avatar for vegaseat
0
219
Member Avatar for kalel21

I wouldn't recomment assembly as your first language. There's a different dialect for every architecture you program on, and even though the language is relatively small and simple, the problem is putting small and simple pieces together. It's easier to work with a language that doesn't require you to build …

Member Avatar for tonakai
0
1K
Member Avatar for vegaseat
Member Avatar for acidburns

The list of things you've done wrong is too long for me to go into detail, so here are the biggies: 1) gets is wrong 2) main should not be called recursively 3) feof is not meant to be a loop condition 4) Your constructs are very inconsistent At least …

Member Avatar for acidburns
0
180
Member Avatar for mel2005

The way you've worded this is confusing. Is the data model like this? [code] Stock No: Price Description Customer No: Name Address Order No: Customer No Date Order Line: Order No Stock No Quantity [/code] If not, be more specific. >The software uses a datagrid attached to the orderline table …

Member Avatar for mel2005
0
91
Member Avatar for kohkohkoh

If the file is in the current working directory, it's just a matter of tacking on the extension and opening the file: [code] string name = "derrick"; ifstream in ( ( name + ".txt." ).c_str() ); [/code] If the file is not in the current working directory, you must supply …

Member Avatar for kohkohkoh
0
77
Member Avatar for msaqib

Those tutorials aren't horrid, but one should be wary of misinformation and poor practice when reading them.

Member Avatar for JoBe
0
112
Member Avatar for lulug76

Okay, you've explained what you're trying to do and the code shows how you're going about it. However, you've neglected to tell us what you're code doesn't do that you want it to. I don't know about everyone else, but I don't have time to analyze every program that somebody …

Member Avatar for lulug76
0
169
Member Avatar for Narue

Since Dani refuses to post, and you people should care enough about the community to follow the log closely, I attached it. ;)

Member Avatar for Dani
0
343
Member Avatar for lulug76

You can search for a number easily: [code] int array[BIG_SIZE]; int n = 0; // ... int r = rand(); int i; for ( i = 0; i < n; i++ ) { if ( r == array[i] ) break; } if ( i == n ) array[n++] = r; …

Member Avatar for Narue
0
116
Member Avatar for bobr_1013

It depends on how you're reading the records. The easiest way is to treat each record as a line and use getline to read them. getline will extract the newline character for you. If you're reading character by character then you may need to use the ignore member function of …

Member Avatar for bobr_1013
0
195

The End.