- Strength to Increase Rep
- +8
- Strength to Decrease Rep
- -2
- Upvotes Received
- 17
- Posts with Upvotes
- 15
- Upvoting Members
- 12
- Downvotes Received
- 0
- Posts with Downvotes
- 0
- Downvoting Members
- 0
190 Posted Topics
| |
Re: Here's an idea: First check is your number teen, or not. If it is teen number (1 is first digit) then check second digit and write: [CODE=cplusplus] //just for example case 1: str = "Eleven"; break; case 2: str = "Twelve"; break; //... [/CODE] if it's not teen number, then … | |
Re: [QUOTE=themaestro;1353847]Thanks for the reply. The code above only writes "time exceeded" after the person has finished the quiz. Is it possible to prompt the command even if the user doesnt enter anything? Lets say he's only less than halfway through the quiz.[/QUOTE] It is possible, and it is called "threading". … | |
Re: Yes, you can, it is called recursion. Look it up on net | |
Re: And yet, scanf can be clever function: [CODE=c] #include <stdio.h> int main(){ char dump, string[40]; printf("Enter whole sentece (yeah, bring spaces too, I can handle it):\n"); scanf ("%[^\n]", string); scanf("%c", &dump); printf ("You entered: %s", string); return 0; } [/CODE] | |
Re: Unix has various flags. It doesn't have to do with makefiles. Try writing instead of _UNIX: _unix, unix, _UNIX_, UNIX... etc... The best thing is: see what compiler are you using, and then look at its documentation, because compilers are setting those flags, and different compilers name different names (for … | |
Re: 1. You are making memory leaks all over the place. When you operate with dynamic memory allocation you have the responsibility to free every part of memory that you don't use. 2. Instead of [ICODE]void main()[/ICODE] always write [ICODE]int main()[/ICODE] 3. myRemove() isn't working. Why are you creating a new … | |
Re: >I'm using Visual C++ and doesnt give me any compilation error it keeps giving me a run time error after i enter the 1st number i can't figure out whats wrong :S help?[/QUOTE] The only reason this code should give you error is if you input something else that float, … | |
Re: I guess you defined float stars[20][20]? You can't write stars[i] + stars[j], because you have to write two dimensions (two brackets): stars[i][j]... always. hth | |
Re: Never test end of file with .eof()!!! It's wrong. Instead, replace [ICODE]!indata.eof()[/ICODE] with [ICODE](indata>>info)[/ICODE] (and of course, remove same line after while) | |
Re: Line 8 of your code is: string constructor (string str, int number) Line 9 of your code is: string constructor (char* arr, int number) It's been awhile since I wrote in c++, but i think you can understand this. The point is that if you type "Initial", that's not object, … | |
Re: Have you called srand()? You need to seed the numbers first. You can look at this example: [URL="http://www.cplusplus.com/reference/clibrary/cstdlib/rand/"]cpp useful webpage[/URL] EDIT: ok, I see srand now :D... Try to break your code a bit... segment by segment, to pinpoint exactly where it goes wrong... For example, try to print rand(), … | |
Hello. I've just started learning Python and I have a few questions. I'm using my program to communicate with some device through serial port using serial.py library. It's all going really fine. I've got a class device, and I'm using it to communicate with a device (logical ;) ). Q: … | |
Re: It should be like this (yeah, I like writing nonesence): [CODE=c] int i = 0; while ((string[i++] = getchar())!='\n'); string[i]='\0'; [/CODE] | |
Re: You could write your hex-to-deci function, and then you can simply write [ICODE]char a = hex-to-deci-function(hex_num)[/ICODE] | |
Re: [QUOTE=sambafriends;727086]thanx for replay can u explain briefly I used void so, there is no need to return any value[/QUOTE] You can drive your car without fastening seat belt, or walk through minefield :) But it's risky! So always use [ICODE]int main()[/ICODE] and return zero if succesful (in which case you … | |
Re: If you are running it under Windows XP CMD than it will only affect that window, because XP just simulates command prompt, doesn't load real one. So, answer to your question, if you are running XP, is NO | |
Re: Please post at least head of your header file... Until then, this: [URL="http://msdn.microsoft.com/en-us/library/f6xx1b1z(VS.71).aspx"]googleing![/URL] says this: [QUOTE]Linker Tools Error LNK2001 unresolved external symbol "symbol" Code references something (such as a function, variable, or label) that the linker can't find in the libraries and object files. Possible causes * What the code … | |
Re: What have you done so far? We don't solve homeworks | |
Re: Problem is you are going both ways! You are incrementing i iterator and at same time decrementing ptr_size2. Write something like: [CODE=C] ptr_size2 = ptr_size; temp = ptr; while (ptr_size2>=0) { temp[ptr_size-ptr_size2]=ptr[ptr_size2--]; }[/CODE] | |
Re: AFAIK brackets can be used without any function or if statement, simply as code-block. They just come in handy for functions, classes, etc. | |
Re: why do you need kbhit? kbhit works more like a detector if key is pressed, it doesn't wait for keypress. Simply use getch? | |
Re: What do you really want? How to create Clist? or? | |
Re: What does Earray point to? You've made it to null pointer: [ICODE]Earray[i] = 0 //like NULL[/ICODE] And your EmpPointer is unused... Seems like to me you're trying to allocate 2D array of some sort, but doing it wrong | |
Re: hmm... write your own mul using logical operators and and or? I'm a beginner too, so don't really know how, but I'd try something with that Although it's not elegant solution | |
Re: It works on my Dev-cpp (mingw, gcc) compiler, and I can't see any problem with code, so it's probably something about your compiler. | |
Re: Well, you obvioulsy need to increment counter each time you add a node, and decrement it each time you remove a node. It's really not hard, just put it in insert, delete, and create list. For checking if list is empty... simply check if first==NULL. But don't you need some … | |
Hi! I have the following code: [CODE=asm] mov al, 5d neg al[/CODE] When it executes, CF = SF = AF = 1 Ok, I think I understand why AF (number is bigger than 00001111b ?), SF (most significant bit is now 1 not 0) But what I don't understand is … | |
Re: Make pointer to pointer [ICODE]**ptr[/ICODE], and allocate n pointers to it. Then to each of that n pointers [ICODE]*ptr[i][/ICODE] allocate n int's (or whatever). After that you can use it as regular 2D array: [ICODE]ptr[i][j][/ICODE] | |
Hello to all of you! I would really appreciate somebody telling me complete step by step tutorial how to work with MASM (or TASM, but I haven't noticed it's free to download) I've tried myself MASM and TASM (some Telemark assembly, not Borland), but for some reason it won't work, … | |
Re: And a little piece of advice. When working with decimal numbers, don't use float, instead use more precise double. | |
Re: What you wrote will only chage 101'th element of array1 with 101'th element of array2. To copy arrays, you have to write function that will do that for each element | |
Re: Let's say you have arrays: [ICODE]int arr1[N], arr2[N];[/ICODE] Then [ICODE]arr1[/ICODE] and [ICODE]arr2[/ICODE] are actually pointers to first locations in arrays, so this would be true: [CODE=cplusplus] arr1== &arr1[0] && arr2==&arr2[0] [/CODE] Now you can see where I'm going at: [CODE=cplusplus] arr1 == arr2 //is like &arr1[0] == &arr2[0] [/CODE] So … | |
Re: [QUOTE=rati;712147]Hi gunjan, Can you please tell me what is the difference between [ICODE] void function(int*d); [/ICODE] and [ICODE] void function(int &d); [/ICODE] both above are function declarations and both we do the changes to the original variable passed to the function. Then what is the exact difference. Thanks in advance[/QUOTE] … | |
Re: If I'm not mistaken, fillellipse draws standard (unrotated) ellipse, and there's nothing you can do to rotate it. You could try to draw your own ellipse, and then do something with that... | |
Re: Using '%' and '/' should be sufficent. First take a modulo 10 of number (and that is your last digit), then divide number by 10 (and you are left with number without last digit). And put that somehow in a for loop | |
Re: Also, when working with classes that allocate memory dynamically, you HAVE to write destructor that will free all allocated memory! | |
Re: [ICODE]- radius = r;[/ICODE] Hmm... What's wrong with this code: [ICODE] -a = 300;[/ICODE] | |
Re: Try to see if the problem is input or your class. Remove all user inputs from main and put something yourself in it. If it works, problem is only in input. | |
Re: Don't know if it helps. I myself am not sure if it's ok to write it, but compiler doesn't complain: [CODE=cplusplus] void func(int n){ int a[n]; for (int i = 1; i <= n; i++) a[i+1] = i*i; for (int i = 1; i <= n; i++) std::cout<<a[i+1]<<std::endl; return; }[/CODE] | |
Re: Err#1: this semicolon here: [ICODE]double getTheoreticalData(double x);[/ICODE] This is not necesarry:[ICODE]double PI;[/ICODE] Since you have included "cmath" header, you already have M_PI defined, and it's more precise than your PI! Err#2,3: y[] is not declared, z[] is not declared Err#4: after [ICODE]return 0;[/ICODE] you need closing bracket '}' for main() | |
Re: Ah, now you've said your problem. Solution is simple: AND && (notice, two & signs) OR || NOT ! | |
| |
Re: Funny: [CODE=c] typedef struct node { char value; bool isroot; bool isend; struct node* sibling; struct node* child; }; //<== if semicolon goes here, it's much more reasonable [/CODE] | |
Re: d is c++ string object, and printf is C function. Even more, not only it's C function (it would probably work nevertheless), but you've told it to print integer ( "%d" tells printf to print integer!) | |
Re: And what exactly is the problem? You have no syntax errors, and I can't see anything wrong. But i'm sleepy, so maybe I'm wrong... Please be more specific | |
| |
Re: You should check your microphone. It can sometimes be a problem (conflicts with compiler for c++) | |
Re: You should use while loop, not for. And you haven't declared 'two' and 'zero'. Why don't you simply put 2 and 0? | |
Re: You're getting char with [ICODE]cin.get(ch)[/ICODE] inside while function. You don't need [ICODE]cin>>ch;[/ICODE] before (it steals one char from you) |
The End.