1,171 Posted Topics
Re: [B]>how to compile c++ program when we r using two different functions which are defined in different file(s) under same directory in linux gcc???[/B] First look at Sky Diploma's post. Second: Well, I would type: [ICODE][B]g++[/B] -o [I]outputfile[/I] [I]file1.cpp[/I] [ [I]file2.cpp[/I] ] [ file[I]x[/I].cpp ][/ICODE] The square brackets indicate an … | |
Re: Well, you could try using the derived maths functions: [LIST] [*][TEX]\sin^{-1}x = atan(\frac{x}{\sqrt{1-x^{2}}})[/TEX] [*][TEX]\cos^{-1}x = 2 * atan(1) - atan(\frac{x}{\sqrt{1-x^{2}}})[/TEX] [/LIST] :) Edit:: Sorry jephthah, I didn't read your post carefully :( | |
Re: [CODE] #include "fstream" #include "iostream" [/CODE] has to be: [CODE] #include <fstream> #include <iostream> [/CODE] Edit:: Why are you using a preprocessor macro? [B]typedef[/B] would be a more accepted way :) Edit:: OP edited/clarified his post, so I removed some things from mine as well :P | |
Re: Hey shamiliroy, did you notice the following sentence just below your first post of this thread: [QUOTE] Last edited by ~s.o.s~ : 17 Hours Ago at 18:49. Reason: Added code tags, learn to use them. [/QUOTE] I want to felicitate you that you've at least tried to use code tags … | |
Re: [QUOTE=Himani_29;912565]i very well knw tht.. n first plz if u cn stp being tht rude.. i hv been successful in making the code tht helps me do the complete task bt for a single file... nw hw do i manage to gt all the files n do the searches..??[/QUOTE] He … | |
Re: [B]>I wrote a code to get factorial for a number uptil 100.[/B] If you even can't print out the result, how can you be sure then that your code is working? | |
![]() | Re: [B]>I also want to read from the passwords file and check if the password has been already generated...... If yes, then generate a new password .....[/B] Well, you could for example at the start of the program, read out all the previously generated passwords from the file, and store them … |
Re: Read the information on the web page below very carefully, and then you can get started by upgrading your code to more decent C++ code. [url]http://siddhant3s.googlepages.com/how_to_tell_rusted_cpp.html[/url] | |
Re: This post has nothing to do with the converting between those two, but with: [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 you want to return value 1 if your program has terminated correctly? Make … | |
Re: [url]http://www.geekpedia.com/KB30_How-can-I-pass-command-line-arguments-while-debugging-within-Visual-Studio-.NET.html[/url] (The steps are the same for your version of Visual Studio) Edit:: This link is not to demotivate you, it doesn't require much reading (only one line of text) and is very straightforward :P | |
Re: [QUOTE=Whilliam;912864]problem solved!!![/QUOTE] Maybe in future, you could mention how you solved your problem, so others, who get to this page (for example by using Google (everyone's friend :P)), having the same problem can see how to fix their problem. | |
Re: [B]>The type of the array is int, so the size of the array is 10 * 4.[/B] To the OP: Yes, on most implementations, this is the case, but certainly not on all. In that example you assume that an integer is 4 bytes. You can get the exact size, … | |
Re: [B]>what should i do first plz help me[/B] Begin creating one of the classes, no matter which one you start with. Do you know how a class skeleton looks like? If no, then I would like to suggest you to read your text book first. Otherwise, give it a shot … | |
Re: [U]Step 1:[/U] Get an integer from the user (store it in a variable) [U]Step 2:[/U] Check whether the integer is higher or lower than zero: [CODE] IF number < zero: Print out the multiples ([B]Step 3[/B]) [/CODE] [U]Step 3[/U] (Get all multiples of 3 for all numbers less or equal … | |
Re: Hi [B]linkingeek[/B], welcome to this forum. Could you please [URL="http://www.daniweb.com/forums/announcement8-3.html"]post using code tags[/URL]? This makes the code much more readable. | |
Re: What??! Already the 5th post and nobody has told the OP to use code tags? To the OP: [url]http://www.daniweb.com/forums/announcement8-3.html[/url] (read that information please, before making any other post, containing code snippets) | |
Re: [QUOTE=firstPerson;912133]How could one share a .exe that loads textures. I am using c++ and openGL. I want to share the .exe that I made using rapidshare.[/QUOTE] Well, isn't the homepage informative enough? It describes you what to do: 1. Click the browse button: browse for your .EXE file you want … | |
Re: Well, my first remark is that you don't have to call a destructor explicitly, it will be automatically called when the object goes out-of-scope (this is for example when you shut down your program), so don't write: [ICODE]~Question();[/ICODE] anywhere in your code. Edit:: ^^ Actually this is just giving a … | |
Re: [B]>Any ideas?[/B] Remove [B]ios::in[/B] :) EDIT:: I usually open files like this if I want to open them in text mode: [CODE=cplusplus] string fn = "test.txt"; ofstream fout; fout.open( fn.c_str() ); [/CODE] (I also used a [B]string[/B] like you did) | |
Re: To the OP: Don't write your code like this: [ICODE]while(os.eof())[/ICODE], instead write it like jencas did. Want to know why? Do a forum search on: feof or eof :) Edit:: I thought it was safely to assume that the 'oef' in 'os.oef()' is a typo he made. (Because [URL="http://www.acronymfinder.com/AFAIK.html"]AFAIK[/URL] there … | |
Re: You'll find [URL="http://www.daniweb.com/code/snippet1068.html"]this[/URL] code snippet helpful :) (If you're not allowed to use vectors, you can always adapt it to use an array) Or use [URL="http://www.cplusplus.com/reference/clibrary/cstring/strtok/"]strtok[/URL]. ![]() | |
Re: Use [B]getline[/B]: [CODE=cplusplus] string s; cout << "Enter some text: "; getline(cin, s); cout << "You typed: " << s << endl; [/CODE] :) | |
Re: Well, your code can be easily fixed, change: [CODE] for (int x = 1; x <= numExs; x++) { [COLOR="Red"]total += x; totalxs = total * 'X'; [B]// (1)[/B][/COLOR] } [/CODE] to: [CODE] for (int x = 1; x <= numExs; x++) { [COLOR="Green"]totalxs += 'X';[/COLOR] } [/CODE] [B](1)[/B]: Wrong … | |
Re: iostream objects are usually slower than printf, but the little efficiency you gain by using printf is not worth avoiding the flexibility of the iostream classes. (remember: iostream is not only cout, cin.) | |
Re: If you specify [B]%d[/B] in the format string of the [B]printf()[/B] function, you also have to specify a corresponding integer value to print. [U]General rule:[/U] For each format specifier you include in the format string, you also have to supply a corresponding value (of the same type as the format … | |
Re: [QUOTE=csurfer;908650][URL="http://www.faqs.org/faqs/jpeg-faq/part1/"]Image Compression[/URL],[URL="http://www.audiodesignline.com/showArticle.jhtml?articleID=192200240"]Audio Compression[/URL] .You couldn't even find this.....?[/QUOTE] In a strange way, people here can't use Google, but they can find the forums :P (That's a relief!) | |
Re: [QUOTE=cool_zephyr;910449]when we do free the memory space reserved by malloc..does it free only the memory space not being used at that time or the whole memory space allocated by malloc??? [/QUOTE] [url]http://www.cplusplus.com/reference/clibrary/cstdlib/free/[/url] | |
Re: Yes, change [ICODE]#include <iostream.h>[/ICODE] to [ICODE]#include <iostream>[/ICODE] and put the instruction using namespace at the top of your code or use the [ICODE]std::[/ICODE] specifier for each object (in namespace std) you want to use :) ... By the way: avoid using [ICODE]void main[/ICODE] it's unnecessary look here: [URL="http://cppdb.blogspot.com/"]http://cppdb.blogspot.com/[/URL] ... | |
Re: And an addition to csurfer's post: Get rid of that [B]void main()[/B], it's evil! Change [B]void main()[/B] to [B]int main()[/B]. >How to convert structure to class in C++? Theoretically in C++ a structure is a class. Edit:: BTW, is your code working? As I cannot compile this crap on my … | |
Re: [QUOTE=gretty;909269]thanks for the links :) Is'nt that tutorial site learning API coding in C & not C++? I am not familiar with C.[/QUOTE] I know, it says that it's for C, but it will work with C++ as well. | |
Re: [QUOTE=Salem;909890]> For example, i want to know how does wxWidgets create there windows, buttons, etc. It's open source, go read the code.[/QUOTE] Well, I guess if he reads the [URL="http://docs.wxwidgets.org/stable/"]documentation[/URL] or some of the tutorials listed [URL="http://www.wxwidgets.org/docs/tutorials.htm"]here[/URL], it will be already more than enough for him :P | |
Re: [QUOTE=imhunk;909582]hello. i want to get a free web space where i can upload my own created designs. i went in with some of the sites but they provide their own templet. so, please help me by giving me some names of such sites. thanks !![/QUOTE] Ever tried finding a free … | |
Re: Declare the stringstream inside the for-loop's body: [CODE] for(i = 0; i < scoreSheet.size(); i++) { [COLOR="Green"][B]stringstream q;[/B][/COLOR] q << scoreSheet[i]; q >> z; cout << z << endl; } [/CODE] :) Edit:: In some cases, you might want to add an additional check as well: [CODE] for(i = 0; … | |
Re: Does your program directly crash after executing it? If no, what input are you entering? Also please answer the following: What compiler are you using? What OS are you on? BTW, what are you going to do when the user enters a negative value at the start of your program? … | |
Re: [QUOTE=tag5;908087]sorry i don't now how to use it please reply,[/QUOTE] Look at the link in adatapost's post :) | |
Re: [QUOTE=csurfer;907336]Well [URL="http://www.microsoft.com/express/vc/"]VC++[/URL],[URL="http://www.bloodshed.net/devcpp.html"]DevC++[/URL] and [URL="http://www.codeblocks.org/home"]CODE::BLOCKS[/URL] are great.And in case you don't like them you can always go back to good'ol Linux for g++.[/QUOTE] Well, actually Dev-C++ and Code::Blocks are both IDEs featuring the MinGW compiler, a port of the GNU Compiler Collection. (e.g: g++, gcc) | |
Re: [QUOTE=member9;902988]i cant understand what does ++*++p means??? can u help me[/QUOTE] Consider the following code: [CODE=cplusplus] #include <iostream> int main() { int a[5] = {0, 5, 2, 3, 4}; int *p = a; ++*++p; std::cout << a[1] << std::endl; return 0; } /* Output: 6 */ [/CODE] Explanation: The first … | |
Re: We can say nothing for sure if we can't see your code, but I can maybe use my physic powers to make a guess. Couldn't it be that you try to access [B]__cpu_features_init[/B] in a place where your program can't see it, or you've made a typo, or you just … | |
Re: Look, I found another post of you, about exactly the same: [url]http://www.daniweb.com/forums/thread201413.html[/url] | |
Re: What you can also try is just recompiling the source of the file which is behaving incorrectly. (I compiled this source successfully using MinGW). What compiler are you using ? Could you just attach the whole file (the source of the file which doesn't work correctly) to this thread? (and … | |
Re: [QUOTE=Dave Sinkula;904308]Consider [URL="http://www.daniweb.com/search/search.php?q=currency+converter"]searching this site[/URL].[/QUOTE] Eureka! I've found one, Dave: [URL="http://www.daniweb.com/code/snippet258.html"]http://www.daniweb.com/code/snippet258.html[/URL] :) | |
Re: When running this code, variable [B]w[/B] contains an unknown value, this will nearly always cause an array override (unless you've much much luck). You've to (explicitly) assign [B]w[/B] a value as well, before using it anywhere in your program. [CODE] for ( i=3; i<[B]sqrt(100)[/B]; i++ ) { if ( [COLOR="Red"][B]x[w][/B][/COLOR] … | |
Re: [B]>WARNING: NO NEW LINE AT THE END OF FILE >What should I do?[/B] Move your cursor to the end of the latest line of your file and press ENTER. Then try recompiling your source, the warning should be away. | |
Re: Look: [url]http://www.daniweb.com/forums/post906316.html[/url] Edit:: This double-thread is deleted by an Admin. | |
Re: To generate an executable you should 'Build' it, compiling is not enough. If you've compiled it, you still have to 'link' it to an executable file. The 'Build' menu command will do these things both: it first compiles your source, and thereafter it links your compiled object file to an … | |
Re: [QUOTE=salie_90;906187]i need help please...i ask, to make a program that accepts a positive integers and displays all odd number between 1 to the integer entered (inclusive) accept the integer in main() and use a recursive function to identify and display the odd numbers. tnx..salie[/QUOTE] Don't resurrect old threads to just … | |
Re: I'll give you a small start: (assume [B]number[/B] is an integer variable) A number is odd when the modulus is not equal to 0. For example: [CODE=cplusplus] if( number % 2 ) { // The number is odd } else { // The number is even } [/CODE] BTW, What … | |
Re: It's not recommended to just program it like that because you return a pointer to a local (automatic) variable, and when the function returns, the variable will be 'destroyed' (this means: it doesn't exist anymore, the memory assigned to it will be marked: "allowed to use"), but you still have … | |
Re: A simple example demonstrating a string passed by reference: [CODE=cplusplus] void func(string &s) { s += " something."; } [/CODE] This is just a useless function which adds "[B] something.[/B]" at the end of the string passed to the function, but it demonstrates the use of references. A call to … | |
Re: [URL="http://www.daniweb.com/code/snippet1068.html"]http://www.daniweb.com/code/snippet1068.html[/URL] |
The End.