420 Posted Topics
Re: 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 … | |
Re: [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 … | |
Re: 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 … | |
Re: 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> … | |
Re: 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 … | |
Re: 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) | |
Re: 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? | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: [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 … | |
Re: 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.. ) | |
Re: 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 … | |
Re: 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] | |
Re: [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 = "*****"; … | |
Re: [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 … | |
Re: [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) … | |
Re: [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] | |
Re: 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 … | |
Re: 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 … | |
Re: Did you read this post? [url]http://www.daniweb.com/forums/announcement8-2.html[/url] | |
Re: 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. … | |
Re: [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 … | |
Re: 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] | |
Re: [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 … | |
Re: 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] | |
Re: [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 … | |
Re: 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 … | |
Re: 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] | |
Re: [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 … | |
Re: [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? … | |
Re: [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 … | |
Re: [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 … | |
Re: 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] | |
Re: [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 … | |
Re: 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 … | |
Re: 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 | |
Re: 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. … | |
Re: [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] … | |
Re: [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 … | |
Re: 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 << … | |
Re: 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? | |
Re: 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 … | |
Re: [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 ) ; … | |
Re: 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 … | |
Re: 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 | |
Re: 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 … | |
Re: Take a look at this file I/O tutorial - [url]http://www.cprogramming.com/tutorial/cfileio.html[/url] | |
Re: 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) |
The End.