190 Posted Topics
Re: Line 30: [ICODE]return 0;[/ICODE] should be inside main function | |
Re: As far as I see [URL="http://msdn.microsoft.com/en-us/library/ms633499.aspx"]here[/URL] it should be: [ICODE]notepad = FindWindow(NULL, "Notepad");[/ICODE] | |
Re: [ICODE]float monitorhire ( float hireleft,float hireout) ;[/ICODE] This is wrong declaration inside main()! Advice: don't use so much global variables (none would be best) | |
Re: Have a look: [URL="http://www.cplusplus.com/reference/stl/set/"]set[/URL] | |
Re: Guessing game? Well, ok... what kind of guessing game? And if you really have code, post it, please. And use code tags! [code][/code] | |
Re: Easy :) But now, do you want us to code it for you? Or would you like to try it yourself? | |
Re: [QUOTE=msundastud;716933]can't figure out what I'm doing wrong....[/QUOTE] A lot of things! First, recheck your syntax, there are many errors. And you cannot declare [B]void[/B] function and then expect to get some result from it! | |
Re: Although, if you're doing it for class of some sort, wouldn't it be better to make your own toupper? Just a thought. Remember, letters are stored actually as ascii code, and you can "add" them or even compare them ('a' > 'A' i think, maybe opposite) | |
Re: Reason is that sstr is set to false AFTER trying to read after EOF. So first you read last item, it's ok, when while sees no error, continues, but you can't read more, so x is assigned to last good reading (last number) AND then sstr is set to FALSE! … | |
Re: I (and presumably lots of people) don't understand your question at all. Maybe providing us with some example of what you want to do or something | |
Re: I tried to count lines to see which one is line 39, and I managed it case 'I' : case 'i ' : Notice that second 'i ', do you see a difference between: 'i' 'i ' First is valid, second is invalid! Change that first | |
Re: For hundreth time: you don't call void function like: [ICODE]void myfunc()[/ICODE] but by simply typing: [ICODE]myfunc()[/ICODE] And what do you want with divide_by_zero()? | |
Re: You don't even need that, since you have a number before your matrix that tells you how big it is. Simply add second number after that, do some sort of while/for/do-while/goto loop (ok, maybe only while or for :) ) and it should work. If you want more help, post … | |
Re: Your code doesn't even compile properly. What is this: [ICODE]if(nho>0)[/ICODE] fix it | |
Re: [LIST=1][*] First you write code in some text editor. It doesn't matter what editor, it could even be notepad. Then you have to compile that code. Compilation refers to the processing of source code files (.c, .cc, or .cpp) and the creation of an 'object' file. This step doesn't create … | |
Re: I'm sorry, but your code is quite big. Try posting one question at a time, event if it means opening several threads at once. | |
Re: [ICODE]while( chioce != 'n' );}[/ICODE] should actually be: [ICODE]} while( chioce != 'n' );[/ICODE] Have a nice coding :) | |
Re: int a[m][m] int *ptr = a; int **ptr = ptr[m]; This doesn't make any sense. If you have to assign dynamic memory, you cannot type [ICODE]int a[m][m];[/ICODE]. Yes, you have to use pointers. Don't worry, they're not too scary. And using 2D array of pointers is a little itchy. First, … | |
Re: [QUOTE=cutedipti;714529]H! //everything good till this: For that you just use fflush(stdin) after each input line. so that it will clear(flushes) the previous 'new line' character and take the input correctly. Try out it!![/QUOTE] In C standard fflush accepts only output buffers, not input. Although most compilers do clear std buffer … | |
Re: I think that for binary search you need sorted list... so if you have unsorted array, linear search will have to do. Otherwise, binary is faster | |
Re: your problem is cin>>char_var; Why? When you enter something on your keyboard and then press enter you have entered more characters. eg: YOU ENTER: p CHARS IN BUFFER: p, '\n' That '\n' is from the enter you pressed, and you have to get rid of it before next input. So, … | |
Re: Well, if you're not going to acces members randomly but from begining to the end, maybe list would be perfect? On the other hand, you could use realloc for every n members (you choose n, but I wouldn't go over 100 if user input is small) | |
Re: I believe (but since I'm not familiar with IP thingies, I'm not sure) that you are assigning a bool here: [ICODE]in_addr_t ipaddr = inet_addr( s ) == -1[/ICODE] Is the same as [ICODE]in_addr_t ipaddr = (inet_addr( s ) == -1)[/ICODE] So you should write: [ICODE](in_addr_t ipaddr = inet_addr( s )) … | |
Re: [QUOTE]//i am not sure how to implement an array of linked list without vector[/QUOTE] And that's why I always say: start with C first. If you're making linked list, you don't use []. Inside your main() you just hold head pointer which points at first node. Your create_node code has … | |
Re: well, show us your timeGetDevCaps function for start :) | |
Re: The only problem is he can't use name "continue", it's c++ keyword ;) | |
Re: Please mark this thread solved then | |
Re: int has it's largest number, and you can't insert a larger number in it than that. But I don't think that's even point. Your code asks you to input each digit in NEW LINE. Inputing them on same line will produce digit larger that nine, and thus output: "Invalid Input. … | |
Re: Using stack without dynamic mem allocation is like... ummm... using stack without dynamic mem allocation (LOL) | |
Re: I would recommend g++ (linux, or win) because it's real compiler, and not IDE. Since you are beginner, it's better to start with plain old compiler :) | |
Re: I believe you don't understand exactly process of "overloading" operators. You can really type whatever you want to do. It's just like a function. If you wish, it can print stuff on the screen. So the question is: what do you want it to do? Yet better, how do you … | |
Re: Use strcpy(string_to_be_copied, string_with_values_to_be_copied) to copy one string to another. | |
Re: [QUOTE=Freaky_Chris;714187]*cough* Dev-Cpp[/QUOTE] THIS compiled ok on dev-cpp: [CODE=cplusplus] int main() { DWORD dwThreadId; HANDLE myThread; void *ptr=NULL; myThread = CreateThread( NULL, 0, MyThreadFunction, ptr, 0, &dwThreadId); while(1){ Sleep(3); std::cout << "main"; } std::cin.get(); return 0; }[/CODE] notice the [ICODE]void* ptr;[/ICODE] I suspect problem is in your "HELLO", not in dwThreadId … | |
Re: [QUOTE=unbeatable0;713170]What's IDE? I'm using Dev-C++ (version 4.9.9.2 if it helps...)[/QUOTE] That's IDE. :) IDE stands for integrated development environment. Best to describe it as a compiler and a lot of useful stuff that comes with it, almost always including specific text editor. | |
Re: Use code tags, and ask more specific question | |
Re: [QUOTE=sidatra79;711947]Hi the code u posted is C code and not C++. So u would get better help and more replies if u would post it in the right section.[/QUOTE] Why do you think it is C++? :| | |
Re: It says [QUOTE]If the space cannot be allocated, the object remains unchanged.[/QUOTE] If that was your question? Furthermore, read this, I think it should help you: [URL="http://www.cplusplus.com/reference/clibrary/cstdlib/realloc.html"]realloc() info[/URL] Bottom point is, you can easily determine if memory has been copied to another place: [CODE=c] //ptr is already allocated with malloc … | |
Re: What is numberObs? And I don't get what do you want exactly? | |
Re: @Narue I see you are using [ICODE]goto[/ICODE]. And I know programmers don't like to use goto, so if I may ask: why? :) Did you just use it because it's fastest to write code like that? Or would you still use it because it has more positive than negative sideeffects … | |
Re: [QUOTE=rrreeefff;710582]Here's what I came up with: [code=cplus] //a lot of code [/code] Here are the 2 errors- error C2296: '+' : illegal, left operand has type 'int (__cdecl *)(int)' and cpp(27) : error C2082: redefinition of formal parameter 'i'[/QUOTE] On line 22 you are declaring function. There's no semicolon in … | |
Re: If you want to determine n-th digit (from the back, so second digit in 1234 is 3) in a number, you do this: a = number%(10^n) (now your digit is in first place) digit = a/(10^(n-1)) (now everything is stripped except your digit) That's the algorithm | |
Re: If you'd be so kind to narrow down your problem to a small piece of readable code, please :) | |
Re: You have to pass variables as an argument. If you want to pass one argument of type char to a function that returns bool you declare function: [ICODE]bool Foo(char a_char)[/ICODE] And you call that function like (let's say you already have char letter inside main): [ICODE]Foo(letter);[/ICODE] BUT, if you want … | |
Re: for(j=10;j>=0;j--) { cout<<kavi[i]; } Do you expect your array to be size 10 always? This works, try to see why: [CODE=cplusplus] char kavi[]={"my shiny sword"}; cout<<kavi<<endl; cout<<"now reversing the word"<<endl; int i=-1; while(kavi[++i] != '\0'); i--; cout<<"Length is "<<i<<endl; for(int j=i; j>=0;j--) cout<<kavi[j]; [/CODE] | |
Re: So you want to print '*' n times, where n is a number of hundreds of dollars? $300 - n = 3 $630 - n = 6 $690 - n = 6? (or n = 7?) If so, divide each sale by n and store it in int (in that … | |
Re: And where exactly are you outputing your data? cout<< will output it to screen | |
Re: [CODE]case 'C': case 'c': void Convert(maxTemp, minTemp, unit);[/CODE] What is this? You call void function like all others: [CODE]case 'C': case 'c': Convert(maxTemp, minTemp, unit); [/CODE] | |
Re: Are you sure this code works: [CODE]ll = queue.ll;[/CODE] 'll' is under private section, right? I'm not sure if you can access it. Here's my code example if it helps: [CODE=cplusplus] //operators //= Complex& Complex::operator=(Complex const& aCplx){ if (this != &aCplx){ mNum.Im = aCplx.getIm(); mNum.Re = aCplx.getRe(); } return *this; … | |
Re: And what is the question? Um, ok... I'll give you a hint... something about your for loop is wrong. It will always return that number is prime. Try to backtrack you program if you enter for example number 4. It shouldn't be prime, but... :) And for all those if-statements... … |
The End.