- Strength to Increase Rep
- +6
- Strength to Decrease Rep
- -1
- Upvotes Received
- 14
- Posts with Upvotes
- 11
- Upvoting Members
- 8
- Downvotes Received
- 1
- Posts with Downvotes
- 1
- Downvoting Members
- 1
Re: Why would you want to use graphics.h anyway? It was written for dos, and almost no one runs dos now. | |
I am doing this assignment for my computer science course, and I have to write a function that determines if 'x' can fit into an n-bit, two's complement integer. I am not allowed to use any control statements or operators other than the [ICODE]! ~ & ^ | + << … | |
| Re: Indentation is pretty important too, especially when you have a problem with looping [CODE]#include<stdio.h> int main() { int pcheck = 1,i; int k = 1000 for(i = 2;i < k;i++) { if((k % i) == 0) { pcheck = 0; break; } } if(pcheck) { printf("%d is a prime .\n",k); … |
Re: You need to somehow determine what the input file is like through arguments or cin, and then write a loop around the calculations that reads the data from the file until the sentinel value is reached. It looks to me like you just posted the code from that assignment #3 … | |
Re: Like WaltP said, you should have the command write to a file and then read from that file. You should probably use the "system" function in stdlib.h. You don't have to "embed" a shell inside of your C program. Also, the good thing about the find command is it lists … | |
Re: Are the [ICODE]ALLEGRO_BITMAP, ALLEGRO_EVENT, ALLEGRO_EVENT_QUEUE[/ICODE] identifiers macros, or just normal types? | |
Re: Although Ancient Dragon's solution should work, the problem with your original code is probably with the byte order. Most modern computers have little endian byte orders meaning that the bytes are stored least significant to most significant, e.g. a 16-bit integer of 0x1234 would be stored as the 8-bit bytes … | |
Re: [QUOTE=wildplace;1537133]yah..=D that works for me.. and a other question.. if my system is 32bit, i coulnt use 64bit registers?[/QUOTE] Then just replace "%%rax" with "%%eax" and "movq" with "movl" | |
Re: [QUOTE=Narue;1540386]It's a gross generalization, but in my experience, if the publisher is out of India, it raises red flags; I have yet to see a decent beginner's book on programming come out of India. Can you learn from these books? Absolutely. Will you pick up an excessive number of bad … | |
Re: If you don't have a question, then this should go under code snippets. Also, it would be best to stay away from non-portable deprecated libraries such as graphics.h and conio.h | |
Re: [QUOTE=abhimanipal;1539761]Quick question do you know the relevance of the keyword extern ? I removed extern and the program compiled with just 1 warning[/QUOTE] The extern keyword means that the variable is defined outside of that source file. The warning you got probably came from using the variables that were declared … | |
Re: In 32-bit protected mode, interrupts are used as exception handlers, like what Athelas said. They are essentially handled exclusively by the operating system and the hardware. And in 32-bit pmode, you can't call an interrupt from your program (unless your program is the kernel or a driver.) In 16-bit real … | |
Re: You never include <string> or <iostream> in your header file so the "string" class is undeclared (you should put "using namespace std;" in your header too). Also you are using names for your get, set, and variable declarations for your strings. | |
Re: If your writing a program for windows XP, not DOS, then your target executable should really be a .EXE not a .COM | |
Re: Arrays work the same in 16-bit and 32-bit, you just have to allocate enough memory on the stack that you need. [CODE]; allocate space for an array of 10 bytes sub sp, 10 mov bx, sp ; bx is the pointer to the start of the array[/CODE] | |
Re: That is platform-dependent, what OS do you have? The easiest solution would probably just be to use the system() function with a console command that would do that for you, like "find" on *nix systems. | |
Re: [QUOTE=WaltP;1535617]Where is [iCODE]strdup()[/iCODE] defined? How is it defined? It's not an ANSI function.[/QUOTE] strdup is part of the GNU C library which can be found basically every linux machine. It is a declared inside of string.h. It duplicates a string like strcpy, but uses malloc so it can be freed … | |
Re: You never allocate any space for the char pointer [ICODE]arg[1][/ICODE]. You could either call a function like malloc and dynamicly allocate space for that c-string, or you could declare the c-string to the stack, like [ICODE]char arg1[100];[/ICODE]. | |
Re: In string constants enclosed in quotes, the backslash\ is used as an escape sequence so you can put in characters that you normally couldn't type into the string, like \" or ' so you have to use the escape sequence for the \ in the file name which is just … | |
Re: You could also take out the prototypes for those constructors. | |
Re: In your for loop in the traverse function you have the condition [ICODE]list.next()<=list.length()[/ICODE], but list.next returns a bool value, meaning that it is either 1 or 0. And since the length never changes inside that loop, that loop is infinite unless you enter the loop with the list having a … | |
Re: [QUOTE=Software guy;1484359][code] #include<stdio.h> int main() { int i,j,temp; printf("\nEnter the Number :"); scanf("%d",&temp); switch(temp) { case 1: for(i=0;i<5;i++) { for(j=0;j<=i;j++) { printf("*"); } printf("\n"); } break; case 2: for(i=5;i>0;i--) { for(j=0;j<=i;j++) { printf("*"); } printf("\n"); } break; case 3: for(i=5;i>0;i--) { for(j=0;j<=i;j++) { printf("*"); } printf("\n"); } break; case 4: … | |
Re: In your scanf statements, you are dereferencing a pointer and then referencing that, which basically does nothing. You pass pointers into getDate, so you don't need to dereference of reference anything, you can just write it like [CODE]scanf("%c", vehic);[/CODE] | |
Re: It probably doesn't have to do with the source code. I think it is because that the compiler/IDE you are using doesn't have write permissions for your target. Try running your compiler/IDE in administrator mode and then building the project again. If that doesn't work, you could try deleting the … | |
Re: I would recommend that you use an std::string instead of a char*. std::strings are safer than char*s and don't require functions like strcpy. So for example: [CODE]std::string highest_str; //you don't need the "std::" if you have "using namespace std;" in your code //...some code here... highest_str = "January"; //...some code … | |
Re: You also should be able to replace the "600" in Unseen Machine's example with a call to [ICODE]dbScreenHeight()[/ICODE] for readability and so that you don't have to change that in the case that the screen size changes, but you still should adjust that value to the rocket's size by subtracting … | |
Re: In your while statement on line 35 you are using a %s to get input for a float, I don't know what result this will produce from fscanf, but it is possible that the loop is never entered and that the calday is never called, and even if it is … | |
Re: Wrong forum, this should be in Hardware & Software->Microsoft Windows->Windows Vista and Windows 7. |