1,171 Posted Topics
Re: [QUOTE=ermithun;904798]Hello All Can anyone provide me a sample code, executing which generates a segmentation falut. need to understand how it works. Thanks.[/QUOTE] If you really want it: [CODE=cplusplus] for(int *p ;;) *p = 5; [/CODE] Good luck with it :P Edit:: But I really don't see how you'd understand it … | |
Re: [QUOTE=XTRobot;901886]on,i have heard of API and GUI what is the diference ? [/QUOTE] Most of the time, the functions to create a GUI are part of an API, but the difference lies in the fact that an API doesn't necessarily have to feature a GUI, we could for example talk … | |
Re: Should the program prevent input like: [ICODE]A3--5,9-01[/ICODE] ?? Is it allowed that the problemset's name contains more than 1 character ? What to do with things like: [ICODE]A35,9-01,A-Z-9[/ICODE] ??[B] >And then convert it back to char with itoa()[/B] itoa() is non-standard. | |
Re: First create an integer type (of the GNU MP library), and then have a look at this: [URL="http://web.mit.edu/gnu/doc/html/gmp_4.html#SEC11"]http://web.mit.edu/gnu/doc/html/gmp_4.html#SEC11[/URL] | |
Re: [QUOTE=nirav99;903612]if you have to make a fact. of x for(i=x;i>=1;i--) { fact=fact*i; // fact = 1 } cout<<fact; put this logic in your program.. it should be work..[/QUOTE] Check your profile, how many times do you want to hear saying us: "Use code tags!!" ?? Information about code-tags is spread … | |
Re: [QUOTE=lotrsimp12345;904291]i have created a C string of my variables and guessing i need some king of loop to check each character after it gets it?[/QUOTE] Could you please post the code you have? | |
Re: [B]>Any clue to the solution???[/B] Yes, start with the structure. | |
Re: [U][B]Struct(ure):[/B][/U] In C++ you could say that a [B]struct[/B] is also a sort of class, but when someone uses the struct keyword, he's often just referring to a structure as ([B]POD[/B] = Plain Old Datatype), POD means that it's used as they did before in C: a structure is used … | |
Re: Could you please post using code tags? Information about code-tags is posted all over the website : 1) in the Rules you were asked to read when you registered 2) in the text at the top of this forum 3) in the announcement at the top of this forum titled … | |
Re: That's because for each integer printed, all operations will be executed. For example, with me this would give the following output: [ICODE]4 5 4 5 4 5[/ICODE] The first integer printed, is the result of all the following operations, executed directly after each other: [B]i,i--,--i,i++,--i,i++[/B] Let's step through this: At … | |
Re: [B]>"->" is used to access data members on the heap[/B] The arrow operator [B]->[/B] is used to access data members (of a class) via a pointer, these data members do not necessarily have to be on the heap, consider the following example: [CODE=cplusplus] // declaration of the 'counter' structure: struct … | |
Re: [B]>Is there any way to build the program, so that it is an .exe file that can be used independently?[/B] Yes, sure there is! I assume you can run the program from within Visual Studio? In that case you just browse to the folder where your project is saved in, … | |
Re: [B]>Do you think this would cause memory problem?[/B] Well, that actually depends on how much RAM there's inside your computer, whether you're planning to create arrays of structures, etc. ... You can quickly check how much bytes a structure occupies in your computer's memory by using the [B]sizeof[/B] operator. You … | |
Re: [B]>First make sure in your code every time you open a file you close it.[/B] Any [B]fstream[/B] (and thus also [B]ifstream[/B] / [B]ofstream[/B]) object has what's called a [B]destructor[/B], this destructor will close the file automatically when the file-object goes out-of-scope. So actually there's no need to explicitly close a … | |
Re: And a little addition to niek_e 's post: To get the amount of bytes a[B] float[/B] and a [B]double[/B] occupy in memory (on your implementation), you can use the [B]sizeof[/B] operator: [CODE=cplusplus] cout << "Float: " << sizeof(float) << endl; cout << "Double: " << sizeof(double) << endl; [/CODE] | |
Re: [URL="http://siddhant3s.googlepages.com/how_to_tell_rusted_cpp.html#SECTION00044000000000000000"]http://siddhant3s.googlepages.com/how_to_tell_rusted_cpp.html#SECTION00044000000000000000[/URL] | |
Re: [QUOTE=Tom Gunn;897794] [code=c] struct test { int first; int second; int third; }; struct test a = {0, 0, 1}; /* Old way */ struct test b = {.first=0, .second=0, .third=1}; /* New way */ [/code] [/QUOTE] Seems like the new way is always longer if you want to initialize … | |
Re: Could you please [URL="http://http://www.daniweb.com/forums/misc-explaincode.html"]post using code tags[/URL]? It looks better to me if you'd migrate your code to be more standard, [URL="http://siddhant3s.googlepages.com/how_to_tell_rusted_cpp.html"]this guide[/URL] will help you to accomplish the task :) And also: what problem are you having with this code? (you only posted your code, but you didn't ask … | |
Re: Could you post down your code (please use code tags) and the contents of the file as well? | |
Re: Hey, why not telling him to post using code tags? [U]To the OP:[/U] Information about code tags is spread over whole Daniweb: 1) in the Rules you were asked to read when you registered 2) in the text at the top of this forum 3) in the announcement at the … | |
Re: Have you already tried to solve it? Edit:: Where are you having problems with? | |
Re: [QUOTE=kris4th;902160]I need to create a program that adds two sets, hint: the set is composed of distinct (integer) How to do this using this Function: void add(int result[],int item,int *count); add result the value of the item. Please i really need ur immediate help...pls600x[/QUOTE] Well, here's my immediate help: Can … | |
Re: Quote: [QUOTE=Salem;902176]What is your C++ question?[/QUOTE] And let it say me again: What is actually [B]your C++ question[/B]? It's pretty much difficult to solve a C++ problem, if we even don't know the problem :P | |
Re: >Need an idea Well, you've got pretty much everything you need to start writing code. Could you first write some code and post it down? Also tell use where you've problems with to implement. Problems in writing code? Try to break the problem down into separate small problems (this process … | |
Re: [B]>Well, now you know how it feels to get negative rep[/B] Are you implying that you gave him bad rep only for giving someone bad rep? BTW, Do you really think he's crying for getting 1 point bad rep? He only doesn't find it nice if you give him bad … | |
Re: [QUOTE=csurfer;901678][B]Answers:[/B] [B]1>[/B]Assume that there is a class as: [code=c++] class check{ int a; public: check() { cout<<"Constructor"; } check(int i) { //copy constructor code } . . [/code] [/QUOTE] Look at this: [CODE=cplusplus] check(int i) { //copy constructor code } [/CODE] Why would this be a copy constructor? It's just … | |
Re: Don't use [B]conio[/B] ([ICODE]#include<conio.h>[/ICODE]), it's unportable! To the OP: Are you encountering any problems with your current code? (as you only posted your new code) | |
Re: [B]>I made a game, and my friend told me: It doesn't work on linux.[/B] Because it's a Windows API function. That's why :) [URL="http://www.wxwidgets.org/"]wxWidgets[/URL] probably features a comparable function. | |
Re: You haven't defined the bodies for the constructors: [B]manager();[/B] etc... Edit:: [QUOTE=the_nice_guy;901645] [CODE] [COLOR="Green"][B]/*** Fixes to make it compile are made in Green ***/[/B][/COLOR] #include<iostream> #include<string> using namespace std; class base_employ { protected: string First_Name; string Last_Name; double Salery; public: base_employ() [COLOR="Green"][B]{}[/B][/COLOR] base_employ( string &FN, string &LN, double S) { … | |
Re: [QUOTE=SP IT;901517]I really need you all's help.[/QUOTE] Great! Start a thread in the appropriate forum (about the topic where you require help for) and we'll be glad to help you out. Remember to not forget to read the forum rules + the member rules before starting any thread :) | |
Re: Could you please post using code tags? Information about code-tags is available all over Daniweb : 1) in the Rules you were asked to read when you registered 2) in the text at the top of this forum 3) in the announcement at the top of this forum titled Please … | |
Re: [B]Edit:: Direct after replying I noticed the date of the last post. Edit:: However, this might still be a useful advice for anyone who reads the thread.[/B] [B][U]Bad coding practices![/U][/B] [LIST=1] [*][ICODE]!fin.eof()[/ICODE] Check out [URL="http://www.gidnetwork.com/b-58.html"]this[/URL]. [*][ICODE]system("pause");[/ICODE] Check out [URL="http://www.gidnetwork.com/b-61.html"]this[/URL]. You could use [ICODE]cin.get()[/ICODE] as a replacement. [*][ICODE]return 1;[/ICODE] Why would … | |
Re: >it simply skip it when i put values for Course Name and press enter it go to the next line which is code.. can any one tell me any solution.. Yes, [URL="http://www.daniweb.com/forums/thread90228.html"][B]this[/B][/URL] will help you out :) | |
Re: And here the complaining starts all over: Don't use [B]void main()[/B], it's evil!! [URL="http://siddhant3s.googlepages.com/how_to_tell_rusted_cpp.html"]Migrate to standard C++[/URL] [B]>but i was unable to display numbers like 365 in words[/B] Well, where do you think the "hundred" will be inserted ? Why using [B]goto[/B] if you can easily use a [B][URL="http://www.cplusplus.com/doc/tutorial/control/"]while[/URL][/B] loop … | |
Re: The [URL="http://gmplib.org/"]GNU MP Bignum[/URL] library is a very good one :) | |
Re: [QUOTE=athlon32;899919]Just few quick question: How often are pointers to functions used? Should i implement them in my programs?[/QUOTE] To be honest I have never had to use them up until now. You should only implement something in your program if there's need to, it's not because you've the possibility to … | |
Re: And if you only want the file names then use: [CODE=DOS] dir /b > files.txt [/CODE] :) Edit:: You can also combine this one, with sknake's one: [CODE=DOS] dir /b /s > files.txt [/CODE] | |
Re: This program is real rubbish, old style headers, conio, half of the code is commented out, system("pause") (don't use it), etc... My recommendation is: [URL="http://siddhant3s.googlepages.com/how_to_tell_rusted_cpp.html"]migrate to standard C++[/URL] first, they really should make it a forum rule... BTW, Does it really hurt you to use code tags: 1) in the … | |
Re: [B]>i mean give letter B value smaller than the value of the letter A , is it possible ?[/B] Yes. [B]>and what is the real benifet of the enumeartion in general ?[/B] Consider this: [CODE=CPLUSPLUS] enum animal {CAT, DOG, FISH, COW}; animal a = FISH; if( a == FISH ) … | |
Re: [B]>is there anyone who could help. thankss very much. this is due on 7th July . [/B] Seems like someone is thinking that we will do it for him. Could you maybe first post what you have so far? Edit:: If you had searched the forums before posting your homework … | |
Re: 28 Posts, and no code tags?? [QUOTE] Information about code-tag is posted all over the website : 1) in the Rules you were asked to read when you registered 2) in the text at the top of this forum 3) in the announcement at the top of this forum titled … | |
Re: [QUOTE=William Hemsworth;899040] I'm not even going to bother trying to understand that code, but it's full of small bugs such as this:[code]if(number[i] [B][COLOR="Red"]=[/COLOR][/B] pi || number[i] == PI || number[i] == Pi || number[i] == pI)[/code]Not to mention the entire line is pointless anyway. My advice for you is to … | |
Re: [U][B]A quick guide on passing variables by reference, using pointers[/B][/U] Consider this function: [CODE=C] void padd(int *p, int b) // create a pointer to an integer variable (parameter) { *p += b; // add the value in 'b' to the number } [/CODE] You'll have to use the function like … | |
Re: You could easily use a loop for things like this: [CODE] cin >> Number[0]; cin >> Number[1]; cin >> Number[3]; cin >> Number[4]; cin >> Number[5]; cin >> Number[6]; cin >> Number[7]; cin >> Number[8]; cin >> Number[9]; cin >> Number[10]; cin >> Number[11]; cin >> Number[13]; cin >> Number[13]; … | |
Re: [B]>Memory is deleting here???...what is happening....?[/B] Well, my eyesight is not good enough to see your code from here :P Could you post it please? | |
Re: [QUOTE=adatapost;897549]Use typeid keyword. [CODE=C++] cout << typeid(p).name(); [/CODE][/QUOTE] And include the [B]typeinfo[/B] header: [ICODE]#include <typeinfo>[/ICODE] :) | |
Re: Smart trick, using two different accounts to post the same question across multiple forums on Daniweb: [URL="http://www.daniweb.com/forums/thread199505.html"]http://www.daniweb.com/forums/thread199505.html[/URL] [URL="http://www.daniweb.com/forums/thread199506.html"]http://www.daniweb.com/forums/thread199506.html[/URL] Congratulations! You've just decreased you own chances of being helped by the people here :) | |
[B][COLOR="Red"]First:[/COLOR][/B] I'm not asking how to do this, just carry on... Hey, I found a nice link on how to read C/C++ declarations: [B][URL="http://unixwiz.net/techtips/reading-cdecl.html"]http://unixwiz.net/techtips/reading-cdecl.html[/URL][/B] I'm leaving it here for anyone... I hope it will be useful to you! | |
Re: Normally code is wrapped between code tags, [URL="http://www.daniweb.com/forums/misc-explaincode.html"]learn how to use them[/URL] and increase your chances of being helped by the forum members :) |
The End.