420 Posted Topics

Member Avatar for biganimal

I can see that C++ and python have a few similarities in syntax, but apart from that they're two very different languages, I've never used eclipse (or python for that matter), but I don't imagine that there is any easy way to magically translate your program into C++. Just by …

Member Avatar for vijayan121
0
5K
Member Avatar for cheongsiwei

[QUOTE=cheongsiwei;407832]Sorry ancient dragon ... hopefully this time i can get the code tag works... Now i had no problem with the initialising of datas , but i am not too sure how to get the derived classes work in my program(as mention in the first post , i need a …

Member Avatar for JRM
0
210
Member Avatar for jbennet

After you retrieve data from your input file, convert your string, [I]line[/I], to an int. (Which can be done easily using a stringstream) then you can compare the two highscores, and only choose to overwrite the existing one if the new one is higher. A few other comments regarding your …

Member Avatar for jbennet
0
165
Member Avatar for Akilah712

Why are you copying the file contents out of a filestream, into a stringstream, then, into a string, and then, into another string? you can extract each line of the file one by one straight into your vector, without all that fuss... [CODE=CPP]#include <iostream> #include <vector> #include <fstream> #include <string> …

Member Avatar for Akilah712
0
282
Member Avatar for Hamrick

I can think of one way which would involve both _next and _prev being stored in an array, size 2. The idea being that they're indexed by a boolean value, so that you can "flip" between the two. Your indexes might be node::pointer[true] for _next, and node::pointer[false] for _prev You'd …

Member Avatar for Bench
0
97
Member Avatar for tformed

You don't need to use switch at all, try the STL map container instead, where you can link strings to other strings (just like in a dictionary)

Member Avatar for Killer_Typo
0
4K
Member Avatar for mauro21pl

You tell us..? we're not mind readers. What problem are you having? does it compile? if not, what error message(s) do you get?

Member Avatar for ~s.o.s~
0
158
Member Avatar for RohitSahni

Don't use atoi() - here's how to do it in C++ [CODE=CPP]#include <sstream> #include <iostream> int main() { const char* foo("1234"); std::stringstream ss(foo); int i; if( ss >> i ) std::cout << "i is: " << i ; else std::cout << "error"; } [/CODE]The reason for using stringstreams is that …

Member Avatar for ~s.o.s~
0
32K
Member Avatar for gattispilot

imsorryicantunderstandwhatyourquestionisbecauseitlookslikethis Try rearranging your post without the LaTex tags Although, with reference to the subject line - look at the private members in your class (Of which there are far, far too many... if i were you, the first thing i'd do would be to look at a way to …

Member Avatar for gattispilot
0
340
Member Avatar for mauro21pl

Whenever you're trying to track a whole list of compiler errors, [B]Always[/B] look to fix the first error in the list (usually found on the line of the first error, or the line just before the first error) , then try a recompile before fixing any more. The reason behind …

Member Avatar for Bench
0
143
Member Avatar for hinduengg

[QUOTE=JRM;402396]AHA! So that probably explains why this works, even though "per" was declared as a character array: [code] cout<<per<<endl; [/code] Am I on the right track? Do have good URL for further reading?[/QUOTE] The reason it works is because operator<<() is overloaded for all the built-in types to work with …

Member Avatar for hinduengg
0
1K
Member Avatar for mauro21pl

I assume you've been given all this code by your tutor..? Where is the implementation code for each of the member functions? (It looks like you've been told to write that) You will need to call a member function which accepts a char* (You have got one of those.. )

Member Avatar for Bench
0
183
Member Avatar for jaepi

Their use and meaning depends entirely on context. For built-in integral types, they are bitwise operators for bit-shifting operations. Under these circumstances, << means "shift left" and >> means "shift right". More commonly, you see them in C++ for input and output. Under these circumstances, << means "Outputs to" and …

Member Avatar for jaepi
0
99
Member Avatar for mauro21pl

if you wanted to save yourself a couple of lines of code, you could do this [CODE=CPP]int temporary = strlen(data) - 1; cout << data[temporary/2] ; [/CODE]

Member Avatar for Bench
0
80
Member Avatar for nautolian

[QUOTE=nautolian;405094] [CODE] int main() { string nameStr = ""; //Not necessary to initialize string topicStr = ""; string t2 = "mom"; string t3 = "sex"; string t4 = "* *"; string t5 = "*"; string t6 = "**"; string t7 = "***"; string t8 = "****"; string t9 = "*****"; …

Member Avatar for Bench
0
276
Member Avatar for mauro21pl

[QUOTE=Hamrick;405098]Can you do this without any problem? [code=cplusplus] int value = 'A'; printf( "%c", value ); [/code] I was told that mixing types is bad.[/QUOTE]there's nothing wrong with mixing char and int per se, although whether or not its 'bad' depends entirely on context. an int must always be at …

Member Avatar for Bench
0
110
Member Avatar for Narue

[QUOTE=Narue;403285][B]Problem: Write some code that reverses words.[/B][/QUOTE] My first thought which springs to mind, is, how would you define a 'word'? is it.. [LIST] [*]A sequence of alphanumeric characters [*]A sequence of alphanumeric characters & punctuation [*]A sequence of purely Alphabetical characters [*]Assuming any particular character set (ASCII, Unicode, etc) …

Member Avatar for Bench
0
498
Member Avatar for go939

[QUOTE=go939;404263][CODE]//source error long long byParam[2] = ""; [/CODE][/QUOTE] Try this instead, to initialise all elements to zero [CODE]long long byParam[2] = { 0 } ; [/CODE]

Member Avatar for Bench
0
132
Member Avatar for ankitrastogi82

Polymorphism occurs because of dynamic binding, which is made possible through use of pointers (The compiler internally represents a virtual function as a pointer, whose value is determined at run time) - however, a [B]static[/B] function is just that - its not a function pointer, but an object which has …

Member Avatar for Narue
0
1K
Member Avatar for M1A1

Maybe you could add it to your INCLUDE environment variables in Windows (Note: exact sequence here may be different on WinXP/Vista ... i'm using Win2K) [LIST] [*]Right-click on [I]My Computer[/I] and choose [I]Properties[/I] [*]Go to the [I]Advanced[/I] tab, and press the button for [I]Environment Variables[/I]. [*]Scroll down the list of …

Member Avatar for Salem
0
89
Member Avatar for Fred1306

Did you read this post? [url]http://www.daniweb.com/forums/announcement8-2.html[/url]

Member Avatar for Bench
0
204
Member Avatar for sadaka

That kind of error usually means you've missed out a definition somewhere - For example, if you've declared something in a header file, such as a function. Elsewhere in your code, you may have called that function, and the linker is unable to find the implementation to go with it. …

Member Avatar for sadaka
0
103
Member Avatar for JRM

[QUOTE=JRM;402878]also, if b had data in it previously, does this cause a memory leak due to abandonment of the heap area formally pointed to by b? Will the statement delete [] b; recover it even after direct re-assignment?[/QUOTE] In the example you gave, you haven't used new[], therefore you shouldn't …

Member Avatar for Narue
0
144
Member Avatar for ankitrastogi82

A couple of ways - which are explained by this link far better than I could. [url]http://www.parashift.com/c++-faq-lite/strange-inheritance.html#faq-23.11[/url]

Member Avatar for Bench
0
117
Member Avatar for ElieK

[QUOTE=Abhishek_jn;402069]Sorry I interprete wrong : what i understand that if i run the bat file then system gets shut down, but it is just keep running the command prompt. shwing the command which i saved i.e. shutdown -r -f -m \\IP -t 60[/QUOTE] And what happens when you just type …

Member Avatar for Bench
0
158
Member Avatar for Naseem89

Check out Bruce Eckel's [I]Thinking in C++, 2nd Edition[/I] (Vol.1), available as a free e-book from his website [url]http://mindview.net/Books[/url]

Member Avatar for Naseem89
0
119
Member Avatar for parthiban

[QUOTE=parthiban;402469]Dragon , thanks for your reply but the program doesn't contain any definition for operator = function[/QUOTE] I believe Ancient_Dragon is aware that you haven't explicitly defined operator=() in your class, which is why he mentioned it. Look at the line in your code which he pointed out - you …

Member Avatar for Bench
0
114
Member Avatar for game_fan

it looks OK so far - Although I would suggest seperating your file input function out away from your book class, unless you want every single book object to hold exactly the same information (When you close a file and re-open it, the file reads from the start of the …

Member Avatar for Bench
0
121
Member Avatar for mauro21pl

If you'd like to have a look at the code for one particular implementation of the STL, then check the SGI website for their source code [url]http://www.sgi.com/tech/stl/download.html[/url]

Member Avatar for krnekhelesh
0
83
Member Avatar for bapef

[QUOTE=phalaris_trip;402388] [code=cplusplus] ... while(std::getline(file,temp)) str += temp; [/code] [/QUOTE] Of the 3 solutions you posted, this is the only one which won't crash and burn once the file hits EOF. the EOF flag is not set until after the stream reaches EOF (A read is attempted and fails) - which …

Member Avatar for Tight_Coder_Ex
0
5K
Member Avatar for krnekhelesh

[QUOTE=krnekhelesh;402201]So you are telling that arguing about whether to use dev c++ or VC++ has got everything to do with the topic WHAT ARE VECTORS? If they are to you then I think you don't understand English.[/QUOTE] Did you read the replies you got at the beginning of the thread? …

Member Avatar for JRM
0
273
Member Avatar for jhayrald

[QUOTE=jhayrald;400134] [CODE=CPP]#include<iostream.h> main() { int n,x,y; cout<<"n="; for (x=1; x<=n; x++) { for (y=3; y<=8; y++) cout<<y; } return 0; } [/CODE] *************** and this was supposed to be the output for that problem.. 345678345678345678 i don't know if my code was correct..so pls do help me because i really …

Member Avatar for ndeniche
0
548
Member Avatar for kodiak

[QUOTE=SebyTheDragon;401571]Hi Guys, I'm having the folowing problem related to the system function. I want to be able to read from a txt file a string [/QUOTE]This part doesn't have anything to do with the system() function - you should look up the <fstream> library for file I/O [QUOTE]and then launch …

Member Avatar for Bench
1
2K
Member Avatar for minigweek

Here's another article which may make interesting reading - Further detail on the Right-Left rule [url]http://www.codeproject.com/cpp/complex_declarations.asp[/url]

Member Avatar for minigweek
1
119
Member Avatar for ndeniche

[QUOTE=JRM;400180]I don't know WHY you need to do thsi, so it's hard to guess what other methods might be appropriate. [/QUOTE] For a statically allocated array, the size must be known at compile time - therefore there's no reason to allow a non-const variable to be used to declare an …

Member Avatar for Bench
0
130
Member Avatar for staceywhit
Member Avatar for kermie

the [I]Cable Disconnected[/I] message when the device at the other end of the cable is switched off is perfectly normal. What are the IP addresses of each workstation? are you able to "ping" each machine from the other in the command prompt console window? Do you have NetBIOS enabled on …

Member Avatar for Bench
0
110
Member Avatar for jaymz1972

Aside from file/printer sharing, does the network work OK? Windows File & Print sharing is usually dependent on NetBIOS - make sure that you have enabled NetBIOS over TCP/IP on both workstations. You will find the option to enable NetBIOS in the advanced TCP/IP settings for your network interface

Member Avatar for jaymz1972
0
133
Member Avatar for laconstantine

You're getting confused between two very distinct topics in C/C++ - Pointers, and function pointers, which are both a rather different kettle of fish. The reason that function pointers can be handled in such a way as shown in your original post is because of the nature of functions themselves. …

Member Avatar for laconstantine
0
149
Member Avatar for MarzenaM

[CODE] for (int i = 1; i <= 3; i++) { InputName( name, mark); [COLOR="red"] symbol( sym, mark);[/COLOR] displayMessage(sym, name); }[/CODE]You've called your symbol function, but you haven't done anything with the returned value. If you don't wish to use the return value, then you will need to pass [I]sym[/I] …

Member Avatar for Gel
0
121
Member Avatar for gitanopalau

[QUOTE]normally runs at 49333 to 51000 bps (THIS I AM CRYING ABOUT). [/QUOTE]Don't expect to get any faster than this on ordinary dialup - it won't happen. In fact, that's pretty good for a 56k modem - My old dialup connection (in the UK on a good telecoms infrastructure) used …

Member Avatar for Bench
0
85
Member Avatar for donaldunca

Its a way of starting an infinite loop which will be stopped using some means other than the condition inside the brackets next to [B][I]while[/I][/B]. eg, [CODE=CPP]void somefunc() { std::string str; while(true) { std::getline(cin, str); if( str == "quit" ) return; else std::cout << "You Typed: " << str << …

Member Avatar for donaldunca
0
128
Member Avatar for ReeciePoo

Do both ethernet ports work individually when plugged into the router (or some other network device) ? What TCP/IP Settings do you use for the ethernet adapters on each computer? (if any, or Automatically detect settings?) Are both ethernet adapters set to autonegotiation for speed and duplex settings?

Member Avatar for nanosani
0
87
Member Avatar for roflol

Take advantage of the fact that characters are represented by integer values on your computer, and therefore may be added to other integer types.[CODE=CPP]char convert(int i) { return (i%26) + 'A'; }[/CODE] EDIT: [I]Note - This depends on the character set on your computer having the letters 'A'..'Z' as a …

Member Avatar for roflol
0
5K
Member Avatar for Duki

[CODE=CPP] openInFile( ifstream & inp , string iNam ) ; readData( ifstream & inp , int ary[] , int SIZE ) ; [/CODE]What are you trying to do here? call the openInFile and readData functions? don't include data types when passing function parameters [CODE=CPP] openInFile( inp , iNam ) ; …

Member Avatar for John A
0
117
Member Avatar for steve_d

The '\0' character marks the end of a 'C'-Style string. in C++, there is the <string> library which lets you avoid the use of raw character arrays. (the C++ std::string type is not too dissimilar to Java's String type). Regardless of whether you are using C or C++, moving the …

Member Avatar for ~s.o.s~
0
100
Member Avatar for jerryseinfeld

There's no difference. manually check to make sure the file exists at the location from which you are trying to open it. Then check the file in notepad to make sure its contents are what you are expecting to read

Member Avatar for jerryseinfeld
0
109
Member Avatar for The Ticket

It sounds as if your server and router are on different IP networks or subnetworks. What are the IP addresses of your Server, your router, and your PC? What IP Address do you get when you obtain an IP Address automatically? to find this information, type [I]ipconfig /all[/I] in the …

Member Avatar for DimaYasny
0
136
Member Avatar for psuspect

Take a look at this file I/O tutorial - [url]http://www.cprogramming.com/tutorial/cfileio.html[/url]

Member Avatar for Aia
0
83
Member Avatar for JoBe

it could be correct if b and d were both of type int* - but since the OP's assignment doesn't say otherwise, a safe assumption is that these are just plain old numbers (or perhaps literals)

Member Avatar for ~s.o.s~
0
191

The End.