519 Posted Topics
Re: What have you got so far ... How do you plan to approach this problem ? | |
Re: @SanJuanWolf Who decided the number of groups ? @Adak Quick question. How do you plan to implement nested loops when the number of groups is a variable I have a dirty solution which may work in this scenario but I am hoping Adak can make that unnecessary | |
![]() | Re: Hi I modified the above program some what ... I tested the program for /bin/ls and /bin/pwd and the program worked. The program makes some assumptions. I will leave them for you to clear out :) [CODE] int main() { char temp[256]; char *argv[100]; char *p; int i=0; int child; … |
Re: When you are reading from the file the value of MAX is 101. But each line has less than 101 characters . So what you want to do is something of this sort [CODE]int main() { FILE *fp = fopen("mytestfile.txt","r"); char arr[100]; // Open a file char *p; if(fp == … | |
Re: atoi is used with string and not chars. [URL="http://www.cplusplus.com/reference/clibrary/cstdlib/atoi/"]This[/URL] link explain the function along with some sample code just google for malloc/ calloc you will find tons of documentation and examples | |
Re: Also why dont you guys write your code incrementally ? Then if you get a compiler error, it is quite easy to spot the reason | |
Re: Have you heard of a little known website called as google.... Try it out.... You might like it Here is what I found in just 0.23 seconds in this website [url]http://www.codeproject.com/KB/audio-video/madlldlib.aspx[/url] | |
Re: Use the code tag.. After you have pasted your code into the little box, select all the code and then click on the (CODE) Preview your post to see if the formatting has come out correctly or not | |
Re: When you just type ls, your code is breaks out at line 79. Check the usage of strtok properly | |
Re: Simplest solutions: Make the variable global . So you want to write some thing of this sort [CODE] char *p = NULL; void func() { p= "Value returned using global variables"; } int main(int argc, char *argv[]) { func(); printf("%s\n",p); return 0; }[/CODE] Or you can return a char array … | |
Re: Xcode hides lots of stuff from you. If your are going to be using C only for a couple of days then probably X code is the right way to go. But if you want to learn the language from ground up, then probably you want to explore the terminal … | |
Re: Try solving the unsolved questions on this forums ... Or check out source forge ... Its full of exciting projects and they always need more contributors there | |
Re: What exactly is your problem ? As the way I see there are many issues with this program. That being said I appreciate the fact that you attempted to work on this problem instead of simply posting "give me the code" Here check out this [URL="http://cslibrary.stanford.edu/110/BinaryTrees.html"]link[/URL] It is very helpful … | |
Re: [QUOTE=westony;1345286]aha :) thanks man :) i get it :) and last question... Do you think that this is the optimal way for linked list or ? Can you give some advice :)[/QUOTE] I dont think the code you have written is correct. What do you wan to do in the … | |
Re: Yes I know the thread is almost a year old but this seemed like an interesting questions and there was no follow up @winrawr I ran your code in a Windows machine and it worked. No seg fault no nothing | |
Re: This seems like an interesting question so I will ad myself to this discussion @Banfa can you explain this concept with a bit of more detail ? | |
Re: Just a small addition to the above post. When ever you declare arrays dynamically you must [CODE]int main() { int *arr =(int *)malloc(sizeof(int)*10); if(!arr){ // Check if you did get the memory you asked for printf("No memory. Terminating program\n"); exit(1); } else{ printf("Sufficient memory found\n"); } // Do operation on … | |
Re: I am not so sure if that was the only reason for your problem . Try running this piece of code [CODE]int main() { char *arr = "ls -l"; char *pch = NULL; printf("%s\n",arr); pch = strtok(arr," "); printf("%s\n",pch); return 0; } [/CODE] This will give you a seg fault. … | |
Re: Well I dont think strtok will give you that What you can do is something like this Use strtok to find the next token Use strlen to find the length of this token. Let this be l1 Now your string of interest is from l1 to end of the original … | |
Re: Bus error is usually because you have tried to access some memory that does not belong to you - You have int arr[10] and you try to access the arr[10] Your best bet is to use printf's to try to narrow down the problem | |
Re: Why do you want to open the num file when both the number and name are present in the numAndName file ? | |
Re: @gudads If this is your first program I suggest you ditch X-Code and work on the terminal | |
Re: I can help you a little bit. My changes are in red [QUOTE=zark_yoc;1329970]show you simple example of pipe [code=c] #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <errno.h> #include <wait.h> int main() { pid_t pid; int pipe_fd[2]; if ( pipe(pipe_fd) == -1 ) { perror("Pipe create error"); exit(1); } if ( … | |
Re: This is my O/P on a mac machine ~$ ./test initial file handle :: 0 child read :: abcdefghij child file handle :: 11 parent file handle :: 28 parent read :: end file handle :: 28 ~$ Maybe some one could shed some more light on this matter | |
Re: How is this related to C programming ? | |
Re: Are you having a problem only with image data or even with simple data as well ? The RST flag is usually raised when a host receives a packet which does not belong to the current connection. | |
![]() | Re: Have you worked with a linked list ? I think all of your functions are some of the most basic operations on a linked list |
Re: 1. Remove the dependency on conio.h 2. void main should be int main 3. No need for getch()/ clrscr 4. Get rid of scanf | |
Re: [QUOTE=sakthi@daniweb;1330069]you can use turing machine concept than finite machines to this..[/QUOTE] What exactly do you mean ? | |
Re: Check out [URL="http://www.tenouk.com/Module40c.html"]this[/URL]. This already has some sample code with it [URL="http://en.wikipedia.org/wiki/Berkeley_sockets"]this[/URL] for a more conceptual explanation | |
Re: I am sorry can you explain a bit more .... What is the exact problem that you are facing ? This is the O/P that I got after running your code $ ./test [1] Stack [2] Queue [3] Exit Enter your choice: 1 [1] Push an item [2] Pop an … | |
Re: If you are planning for multi threading then why not let a thread wait for user input ? | |
Re: Please elaborate more What exactly do you want to know ? | |
Re: Also the OP wants to know the names of the header files not the count ..... If the objective of OP is to prevent including the same header file many times then check out [URL="http://bytes.com/topic/c/answers/892067-header-files-problem-recursive-includes"]this link[/URL] | |
Re: [url]http://www.google.com/search?q=c+program+bisection+method&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a[/url] Next time run a google search for your question before posting it here | |
Re: Also even if you have a very basic knowledge of C and math, calculating the average should be easy | |
Re: If you are interested in fixing your code I would start of by getting rid of the list data structure ... It just adds complexity | |
Re: You have declared the name as a float variable. Change it to a char array Also the correct way to accept a string via scanf statement is scanf("%s",input); PS: Using scanf to take user i/p is a bad idea. It usually leads to a wide varieties of problems. Use fgets … | |
Re: Well to start with try to convert an integer to string . While there are inbuilt functions you can use for this I would encourage you write your own. It will be a good experience if you are new to programming Post your doubts/ questions here | |
Re: Can you describe the problem in more detail ? Simple saying that the O/P is wrong is not sufficient . put some printf's in your code and see how the control is flowing Of the top of my head I see you have used the pointer *tmp but there is … | |
Re: Also the return type of your printDetails() function is int but you are not returning anything from that function. Either make the return type of that function void of return an int value from that function | |
Re: Why is the array not declared ? | |
Re: In the simulator of iPhone you cannot use most of the hardware features like accelerometer, location, camera,etc Besides this the timing and performance results that you get out of a simulator will be very different from that of a real device. So if you want to develop apps for iPhone … | |
Re: Run the code despite the warning . What O/P did you get ? I ran this code [CODE]int main() { int x=5; switch(x >0) { case 1: printf("In case 1\n"); break; case 0: printf("In case 0\n"); break; } return 0; }[/CODE] and this was my O/P $ ./test In case … | |
Re: Quick question ... When you open a file why dont you check if the file has actually been opened or not ? | |
Re: How about giving us some idea of which part of the code is not working ... You know some thing of the sort this should be the expected O/P and this is what I am getting ...... | |
Re: To further develop AD's point [CODE] void func1(int** p) { int x=20; *p= &x; printf("In pointer to pointer to int\n"); } void func(int* p) { int x=20; p= &x; printf("In pointer to int\n"); } int main() { int x=10; int* p= &x; func(p); printf("Value of x now is %d\n",*p); func1(&p); … | |
Re: There are a couple of things If you have [CODE] int x=[1,2,3,4,5]; printf("%u\n",x); // Address of the first element of the arry printf("%d\n",*x); // Value of the element at the address x ie the first element of the array [/CODE] So if you write the statement [CODE]y = ptr - … | |
Re: I ran your code and I got the correct o/p ie 10,4743 Where are you running your code ? Is it a specialized device ? One thing you could do is dont jump straight to 10,000 Go there exponentially you know first calculate the 2,4,8,16,32,64 and so on ![]() |
The End.