1,494 Posted Topics
Re: [QUOTE=damndamn;1136544]please help.. can u give me the codes... :([/QUOTE] Could you give money? | |
Re: [CODE] void dfs(graph g) { printf("whats wrong with me\n"); for (int i = 0;i < g.number_vertices;i++) { g.vertices[i].color = WHITE; g.vertices[i].p = NIL; } time = 0; printf("in dfs\n"); for (int i = 0;i < g.number_vertices;i++) { if (g.vertices[i].color == WHITE) { // dfs_visit(g, i); printf("i: %d\n",i); } } } … | |
Re: I modified your code somewhat to display the intial/final values of c1/c2....What do you notice? [CODE] #include <stdio.h> int main() { char c1 = 0, c2 = 0; fprintf(stdout, "our initial values c1->%d, c2->%d\n", c1, c2); printf("Enter a character: "); scanf("%c", &c1); printf("Enter another character: "); scanf("%c", &c2); fprintf(stdout, "\nour … | |
Re: Here's some code to demonstrate what happens when you cast an unsigned long to unsigned char... [CODE] #include <stdio.h> #include <stdlib.h> unsigned long myint = 1234567890; int main(int argc, char**argv) { int i = 0; unsigned char *cptr = (unsigned char*)&myint;/*cast myint to unsigned char*/ for (i = 0; i … | |
Re: I'm pretty sure you don't have a memory leak...an array out of bounds yes but memory leak no... | |
Re: Because the compiler padded the structure elements up to whole bytes. one byte for signed int a:3; two bytes for unsigned int b:13; and on byte for unsigned int c:1; Try using the attribute packed like below and you'll get three bytes because again the compiler will pad the end … | |
Re: Yup...have some suggestions... 1. use read and write instead of fread and fwrite | |
Re: When you want to left or right shift some bits...or splice some addresses together like below..So when would you need this skill? Hardware programming comes to mind.. [CODE] #include <stdio.h> #include <stdlib.h> unsigned long two = 3345; int main(int argc, char**argv) { unsigned long one = 1234; void *addr = … | |
Re: You know it took Linus Torvalds years to make the very first 'very simple' Linux kernel. If your interested in this area ckeck out Minix. ![]() | |
Re: Please check the result of this action: [CODE] fptr1=fopen("input.txt", "r"); [/CODE] | |
Re: Right from my linux/GNU man file [QUOTE] BUGS Never use gets(). Because it is impossible to tell without knowing the data in advance how many characters gets() will read, and because gets() will continue to store charac‐ ters past the end of the buffer, it is extremely dangerous to use. … | |
Re: You need to post 255 lines of code to ask a question about an array of structures? | |
Re: You realy should google C functions and C control statements....You'll find the answers in these queries... | |
Re: Shouldn't this end with a NULL execve(argv[0], argv, envp, NULL); Ooops my mistake. | |
Re: [QUOTE=jazz_vill;1130436]what i meant is the data files is on another hardrive... my partition table is: /dev/sda3 -this is my C: drive /dev/sda4 - this is my / partition /dev/sda5 - my D: drive /dev/sda6 - my swap partition my data is in in sda5. Thanks for the reply mate![/QUOTE] your … | |
![]() | Re: You said you'd like to write a program - well what do you have so far. |
Re: Well if I had to do this, I would investigate binary trees or get the book "The C Programming Language" which has an example of this code... | |
Re: You should get a table of ascii characters and look up the character equivalent for 10. | |
Re: Try this: [CODE] int main(int argc, char* argv[]) { printf("%lf\n",(0.99F - 0.90F - 0.09F)); } [/CODE] | |
Re: I know this is knit picking... [QUOTE] We all know that we can use the name of an array as the pointer to that array, [/QUOTE] The name of an array is a label which is a convenient human readable memory address. Its not a pointer... | |
Re: As a quick response, I would suggest initializing these local variables to zero. int n,teens,thousands,hundreds,tens,ones,tthousands; | |
Re: Try this web site: [url]http://www.freebyte.com/programming/assembler/[/url] | |
Re: [QUOTE=flipjoebanana;1126320]Is there a way to hide assembly code when my C code references a library function that deals with memory? (Not showing 'asm' code)?[/QUOTE] Maybe if you gave us an example of what your trying to accomplish...Because I'm having a hard time understanding what you mean... | |
Re: Well I guess your not completely switch. I would reinstall Vista and run Ubuntu via Virtual Box since you have the install disks for Ubuntu. [QUOTE] But for some reason I want vista in virtaul machine. [/QUOTE] Sounds like your unsure of your reasoning here... | |
Re: Try this link, it provide some simple examples [url]http://www.metatitan.com/linux/5/how-to-tar-untar-from-the-command-line.html[/url] | |
Re: About [CODE] gets(name); [/CODE] This is what manpages has to says about gets() [QUOTE] BUGS [B]Never use gets()[/B]. Because it is impossible to tell without knowing the data in advance how many characters gets() will read, and because gets() will continue to store characters past the end of the buffer, … | |
Re: [QUOTE=Kombat;1122143]Isn't fgets only used from reading in from a file? Also [code]fgets(a, sizeof(a, stdin) ); [/code] gives error too few arguments Also I realized maybe I should have in arrays instead of char arrays because I am working with bits (1's and 0's) so fgets shouldn't work[/QUOTE] Too few for … | |
| |
Re: Unless its a requirement I won't use fork in this situation...I would use threads.. | |
Re: Volatile tells the compiler that a variable may be changed in ways not explicitly specified by the program - According to C: The complete Reference. This means the volatile variable may be changed by forces outside of the current process(usually the kernel, hardware or another process) so don't make any … | |
Re: Not sure if this is what your looking for.. [CODE] #include <stdio.h> #include <stdlib.h> #include <string.h> struct mystr { char ch1[50]; char ch2[50]; }; void myfunc(struct mystr *str1, struct mystr *str2) { memcpy(&str2->ch1[0], &str1->ch1[0], sizeof(str1->ch1)); memcpy(&str2->ch2[0], &str1->ch2[0], sizeof(str1->ch2)); } int main(int argc, char**argv) { struct mystr str1 = {"string one", … | |
Re: Check this posting for a pipe example: [url]http://www.daniweb.com/forums/thread258136.html[/url] | |
Re: [QUOTE] g++ -Wno-trigraphs -Wno-unused -Wno-deprecated -Wpointer-arith [/QUOTE] Why are you posting C++ in the C forum? | |
Re: The only thing that comes to mind is a using USB key to protect your program settings...What are you writing that requires that kind of security? | |
Re: I tried this and it worked: file1.h [CODE] #define USD 1 [/CODE] file2.h [CODE] #define UKP 1 [/CODE] file3.c [CODE] #include<stdio.h> #include "file1.h" /*#include "file2.h"*/ #ifdef USD #define curr 46 #endif /*#ifdef UKP #define curr 100 #endif*/ int main() { int rs; rs = 10 * curr; printf ( "ans->%d\n", … | |
Re: Try piping the the response back into the program like: [CODE] #include <stdio.h> #include <stdlib.h> #include <unistd.h> enum PIPES {READ, WRITE}; int main(int argc, char**argv) { int i = 0; char ans[256]; char ch; int hpipe[2]; pipe(hpipe); if (fork()) { close(hpipe[WRITE]); dup2(hpipe[READ], 0); close(hpipe[READ]); while ((ch = fgetc(stdin)) != EOF) … | |
Re: [QUOTE] please help me find the error in this code. whenever i try to get the successor, the program gets the status access violation error. i think it's the parameter. [/QUOTE] You think its the parameter...How are passing it to the function and what are some of the values your … | |
Re: [QUOTE=ibuguser;1121089]Hi, I have a program that writes to a specific memory location. I can currently read the value doing this: [CODE] #define address1 0x000F0000 //this is the memory location unsigned long *val1 = (void *) address1; [/CODE] So * val1 contains what I need from the other program. Now I … | |
Re: char slide[20] and int slide(FILE *ifp, char delimeter[], char wild); are both defined to mean two different things...I'm guessing that slide[20] is hiding the function slide. | |
Re: Could we see what you have so far... | |
Re: [QUOTE=pao+kriz;1120689]how about this kind of pyramid? * * * * * * * ** * * * * * * * * * * * * * * * *[/QUOTE] Yeah. How about it? | |
Re: Do you mean reading a file that's composed of the character s '0' and '1'...because when you read/write a file the data is binary... | |
Re: Try this link [url]http://msdn.microsoft.com/en-us/library/h21280bw%28VS.80%29.aspx[/url] In your example try using the octal notation. | |
Re: I think this is what you want: - Note your code generates a [B]memory leak[/B] on line 43... [CODE] # include <stdio.h> # include <stdlib.h> struct test { int data; struct test *link; }; void change(struct test **ptr); int main() { struct test *fresh = (struct test *)malloc(sizeof(struct test)); int … | |
Re: If your using number/base then I would check out the function strtol() | |
Re: uh-ooh you aroused the 'C decency committee' | |
Re: I've seen this extension to the language to handle binary constants...you might be able to incorporate it. Notice the number 0b111 [CODE] #include <stdio.h> #include <stdlib.h> int main(int argc, char**argv) { fprintf(stdout, "ans->%u\n", 0b111); exit(EXIT_SUCCESS); } [/CODE] | |
Re: Could you please use code tags to post your program... |
The End.