1,171 Posted Topics
Re: [QUOTE=Ancient Dragon;845995] [code] #include <al[B]b[/B]orithm> #include <string> using namespace std; int main() { string str = "hello world"; transform(str.begin(), str.end(), str.begin(), [B]tupper[/B]); } [/code][/QUOTE] > I think you've made some typos: > [ICODE]#include <alborithm>[/ICODE] I don't know any 'alborithm' lol :P > I even don't know any 'tupper' :P | |
Re: [QUOTE=gyu12345;858116]i've tried already but still can't. any kind soul to advise on my codes?[/QUOTE] > If you post just use the button with the sharp: '#' and it will generate code tags for you, now you just have to paste your code between them, is that difficult? NO! | |
Re: > If you also are writing the array from your program do as follows: >>> Put the array into a struct e.g.: [CODE=C++] struct sth { int array[5]; }; [/CODE] >>> Now you create a data type from your struct e.g.: [ICODE]sth mydata;[/ICODE] >>> Writing the struct to a file:[CODE=C++] … | |
Re: This code might help you: [CODE=C++] char c; c = 's'; if(('a'<=c && c<= 'z') || ('A'<=c && c<= 'Z')) { /* The character is an alphabetic character */ } [/CODE] | |
Re: You'll have to use the [ICODE]rand[/ICODE] function, look [URL="http://www.cplusplus.com/reference/clibrary/cstdlib/rand/"]here[/URL] for some information about it ... Edit:: A remark on the title of this thread: A computer will never be able to generate real random numbers :) | |
Re: > You could write an Object Oriented Program (of course :P) that represents a 'virtual computer', you'll have to make classes for the processor, the motherboard, the graphical card, the ports (USB, FireWire, Serial, PS/2, etc.), the CD-Drive(s), and much much more :P ... >>You can make this project as … | |
Re: > So if I didn't understand you the wrong way each word may only appear one time ? >>In this case the unique STL-algorithm might be helpful :) | |
Re: [QUOTE=pt_solar;857122]I have a very hard programming challenge and i need help... I have nothing so far, so im hoping somebody could help me build it... [/QUOTE] > Doesn't sound very difficult :) > Sure we can help you as long as you can show us what you've already done and … | |
Re: > Could you please post using code tags? > Which lines are you referring to? (the third and the fourth line??) > According of my knowledge of pointers this: [ICODE]&p[2][/ICODE] is just displaying a memory address (or am I wrong here?) > This code is just the result of (very) … | |
Re: After deleting you could simply set your pointer manually to NULL: [CODE] int *ptr = new int; delete ptr; ptr = 0; [/CODE] By the way, why should [ICODE]delete[/ICODE] reset the pointer to [ICODE]NULL[/ICODE], C++ is a programmer's language and those programmers want to control every single aspect of the … | |
Re: Strange the following is working: [ICODE]final += hex_string;[/ICODE] As far as I know [ICODE]hex_string[/ICODE] is a pointer and [ICODE]final[/ICODE] is a string, but I don't know whether the [ICODE]+ operator[/ICODE] is overloaded for data of type [ICODE]char*[/ICODE] ... | |
Re: There's already a recent thread about this, you can find it [URL="http://www.daniweb.com/forums/thread188723.html"]here[/URL] :) | |
Re: [QUOTE=marthpro899;855831] the file has numbers to but those should be read as a O. need help please help![/QUOTE] > You read a whole line from the file into a string variable and you loop through the string character by character and you evaluate if the character meets the following condition … | |
Re: [QUOTE=siddhant3s;855436]He perhaps, meant that he wants to customize the uranary * operator ( the dereferencing operator) for is custom class. [/QUOTE] He mentions that he just started learning C++: [QUOTE=nature_love;855399]hey guys.. am learning c++ just started..[/QUOTE] I think that's usually not one of the first topics you'll learn (if you're … | |
Re: > If you're using .NET framework: [URL="http://msdn.microsoft.com/en-us/library/system.windows.forms.control.hide.aspx"]http://msdn.microsoft.com/en-us/library/system.windows.forms.control.hide.aspx[/URL] > [URL="http://windows-programming.suite101.com/article.cfm/win32_dynamic_user_interface_trick"]This[/URL] may be more useful to you :) ... | |
Re: Probably it's described in a further chapter of your book, but I still want to give you an example using vectors: [CODE=C++] /* Declare the vector */ vector<int> v; /* Put some values in it */ v.push_back(10); v.push_back(3); v.push_back(30); v.push_back(12); v.push_back(5); v.push_back(23); v.push_back(28); /* Sort the vector from the lowest … | |
Re: > In case you need to use 2D Vectors (this is an alternative to your vector of 'five'-structs) : 1) [ICODE]vector<vector<float> > myVector(5,vector<float>(5));[/ICODE] (this will create a 5x5 vector) 2) You can store data like this: [ICODE]myVector[2][1] = 3;[/ICODE] (store the number 3 in the vector) 3) Printing using cout … | |
Re: > The Complete Reference: C++ from Herb Schildt (1) > C++ Black Book from Steven Holzner (2) I'm not good in reviews, but I'll try to give some comments :): (1) Herb explains everything very clearly and in an understandable way + very detailed explanations, very good examples used in … | |
Re: > Use the [URL="http://www.cplusplus.com/reference/clibrary/cstdlib/itoa/"]itoa function[/URL] / [URL="http://www.cplusplus.com/reference/clibrary/cstdio/sprintf/"]sprintf function[/URL] if you want to convert decimal to hexadecimal (I'm not sure about the fact that the sprintf function will convert a string containing a decimal number to a hexadecimal number, you can simply test it if you want to know it:)) ... … | |
Re: I wrote something equal using strings, look at [URL="http://www.daniweb.com/code/snippet1160.html"]this[/URL] snippet :) so you can see how it' done ... Hope this helps ! | |
Re: Actually this is not very C++ related I think, but OK, can you tell me what error he's having and can you provide me a link to or attach the source of your game to this thread ? | |
Re: [QUOTE=William Hemsworth;855257][CODE=CPLUSPLUS]#include <stdio.h> int main() { printf("%08s\n", "18"); printf("%08s\n", "3048"); printf("%08s\n", "ffff8007"); return 0; }[/CODE][/QUOTE] > Just a little remark on the [ICODE]int main()[/ICODE] line of your code: If a function doesn't require any arguments in C you have to put the [ICODE]void[/ICODE] keyword between the function's '(' and ')' … | |
Re: > Try [ICODE]ofstream fileOut(P.c_str());[/ICODE] instead of [ICODE]ofstream fileOut(P);[/ICODE] :) ... > ofstream requires the filename to be passed as a [ICODE]const char*[/ICODE], the [ICODE]c_str()[/ICODE] method from the string class will convert the string which contains the filename to a [ICODE]const char*[/ICODE] and return it (the string itself remains intact) ... | |
Re: To calculate pi it might be useful to have a high-precision float available where you can store your calculation in, [URL="http://www.apfloat.org/apfloat/"]apfloat[/URL] is really a nice one :) ... | |
Re: > The function [ICODE]cIndex[/ICODE] isn't always returning a value: [CODE=C++] int cIndex(char *x,char **featlist,int len) { int i; for(i=0;i<len;i++) if(strcmp(x,featlist[i])==0) return i; /* So what happens when featlist[i] and x aren't equal ? */ /* You should add a return code to check whether they were equal or not */ … | |
Re: You don't have to use [ICODE]cin.get[/ICODE] for that purpose, just do something like this: [ICODE]infile >> [I]yourvariable[/I];[/ICODE] :) ... Edit:: [ICODE]num1 sign num2 = answer;[/ICODE] will never work (even if you had typed [ICODE]num1 + num2 = answer;[/ICODE] it won't work) ... You'll have to use something like a switch … | |
Re: I don't get your question, can you please explain it in a way I can understand ? By the way, If you've some additional time please format your code properly (using code tags was the first (and very good) step, formatting your code is the second one) :) ... Edit:: … | |
Re: [QUOTE=LanierWexford;852296]I like to write my code in Notebook++. [/QUOTE] I think you meant Notepad++ :) Edit:: What's actually your question ? Do you want to compile a C++ program and run it from console (= command prompt) ? | |
Re: [QUOTE=siddhant3s;854004]>>There are several free compilers, such as Code::Blocks, Dev-C++, and VC++ 2008 Express. ( Note to OP: I am talking to Ancient Dragon, this has got nothing to do with you) I never knew Code::Blocks and Dev-C++ are compilers!! I thought they were IDEs ;) Or am I sensing it … | |
Re: I think you'll need RunTime Type Identification (RTTI) for that purpose ... | |
Re: Please post using code tags :) ... > Change [ICODE]mymembers m[3] = {(20,22),(21,33),(45,44)};[/ICODE] (in your main) to [ICODE]mymembers m[3] = {mymembers(20,22),mymembers(21,33),mymembers(45,44)};[/ICODE] > Edit:: Look at [URL="http://www.java2s.com/Code/Cpp/Data-Structure/Defineandinitclassarraytwointtypeparametersinconstructor.htm"]this[/URL] ... | |
Re: I don't get that, do you mean the following: Is it possible to call a certain function using two different names ? e.g: [CODE] int a = 5, b = 6; [COLOR="Green"] //makeSum and addition do exactly the same [/COLOR] int c = makeSum(a,b); int d = addition(a,b); [/CODE] Do … | |
Re: > [ICODE]int findRows( string line )[/ICODE]: Why are you passing a string as argument, you can also declare a variable inside your function instead ... > [ICODE]return 0;[/ICODE]: I would return -1, as a file can also contain 0 lines :) ... >There's some unreachable code in your function:[CODE] if … | |
Re: > Is this your whole code as it won't compile using any compiler ? > Can you please be more specific in what you need help with ? | |
Re: Take a look at: > [URL="http://www.cplusplus.com/reference/clibrary/cstdio/sscanf/"]http://www.cplusplus.com/reference/clibrary/cstdio/sscanf/[/URL] or > [URL="http://www.cppreference.com/wiki/c/io/scanf"]http://www.cppreference.com/wiki/c/io/scanf[/URL] (sscanf is just like scanf, with the difference that the input is read from the buffer) ... | |
Re: Read [URL="http://www.gamedev.net/reference/articles/article1127.asp"]this[/URL] and [URL="http://www.codersource.net/cpp_file_io.html"]this[/URL] (I think the first link is your best bet) ... | |
Re: [QUOTE=vaps;854509] Does anyone have a sample code, for User Authentication system with the basic functions, login/registration? [/QUOTE] You could simply write something like that yourself, but as you're mentioning 'registration' I've to following question: has to program to interact with the internet to register, or is registering not explicitly required … | |
Re: You could also use a C++ library called 'apfloat' it's freely available [URL="http://www.apfloat.org/apfloat/"]here[/URL] ... | |
Re: [QUOTE=norcominc;73864] I wanna work with some 40 digit numbers here. (I know I'm using int up there)[/QUOTE] Try the apfloat C++ library: [URL="http://www.apfloat.org/apfloat/"]http://www.apfloat.org/apfloat/[/URL] ... | |
Re: Did you read [URL="http://www.daniweb.com/forums/announcement8-2.html"]this[/URL] ? (probably not) | |
Re: [QUOTE=thebluestar;854159] Here is my work, can you help me with the second requirement![/QUOTE] Sure we can help you, but that's such a vague question ... Where are you having problems with ? | |
Re: Can you please post using code tags ? Edit:: Read [URL="http://www.daniweb.com/forums/announcement8-3.html"]this[/URL] and [URL="http://www.daniweb.com/forums/misc-explaincode.html"]this[/URL] :) ... | |
Re: Add [ICODE]extern "C++" int addition(int a, int b);[/ICODE] to main.cpp (outside your main function), delete the instruction [ICODE]external int addition(a, b);[/ICODE] from inside your main function :) ... [B][U]main.cpp[/U][/B] [CODE=C++] #include <iostream> using namespace std; // use the external addition function extern "C++" int addition(int a, int b); int main() … | |
Re: What do you actually expect from us? We won't do your homework ... Edit:: But we can still give you some suggestions here and there :) ... | |
Re: > There's only one place in your function where it explicitly returns -1, (in the else code block) ... > Did you set the studentID variable after you declared a struct-variable from it ? If no, that's the problem :) | |
Re: And what if you consider the following ? [CODE=C++] int array[5]={1,23,45,7,8}; int element_count = sizeof(array)/sizeof(int); /* now this variable holds the value '5' ... */ [/CODE] Edit:: This won't work with multidimensional arrays :) ... | |
Re: Use [URL="http://www.snapfiles.com/get/rockxp.html"]RockXP[/URL] ! It's free and it will recover your Windows XP CD Key :) ... | |
Re: [ICODE]char*[/ICODE] is just declaring a pointer to a character (or an array of characters), and what do you do? You're just assigning a value to it, that's a strong mistake ! You first have to reserve/assign memory to that pointer before you can store a value at the memory address … | |
Re: With me using a vector worked and [ICODE]int matrix[512][512];[/ICODE] didn't (but it still compiled correctly :)) |
The End.