519 Posted Topics
Re: This might get you started. There are 2 string: stringA= hellow , stringB= owl So what you got to do is take the first character of string B and iterate it over stringA from the ending. In this case, we take the character o from stringB and compare it with … | |
Re: You cannot write [code=c] username == 'udental' [/code] Use strcmp instead | |
Re: I am not sure if this will help, but could you over write the data you want to be removed, with spaces ? | |
Re: You could use the division operator to convert marks from 1-100 range to 1-10. Then you just have to write 10 switch cases | |
Re: Here is another idea... It will probably get you started but you have to do more work on it to get the finish product [code=c] void display(int n) { // Right now all the X will be left justified. You have to figure out how to include spaces. int i=0,j=1,num=1; … | |
Re: Your array size is 5 and you want to continuously read the user input till the user exits, how will there be sufficient space in the array ? | |
Hello People, I just came across this code as I was browsing through some C++ problem sets. This code gives compile time error but I am unable to understand the reason. I am C guy and my knowledge about C++ is not that great. So pardon if there is an … | |
Re: Will your input always be a square matrix ? Or the way you are calculating the number of columns is wrong. Read a line using fgets, then copy that line character by character at the appropriate location in the matrix. | |
Re: Do a google search Hint ad i++ after the search string... for obvious reasons | |
Re: Check out this link. This will show you a better method to read an array. [url]http://irc.essex.ac.uk/www.iota-six.co.uk/c/i2_feof_fgets_fread.asp[/url] Define a 2D array of chars (or 1D array of char pointers) As you read a line of the file store it in a row of this 2D array So at the end of … | |
Re: The objective of BFS is to print all the nodes at a given level, then move to the next level In DFS we go depth wise as far as we can go. Then when we cant go any further we backtrack and then try again and so on. DFS gives … | |
Re: Do you have sample input and out put ? Can you post that ? | |
![]() | |
Re: What exactly do you mean by different from all numbers ??? Does it mean that the array has contains many elements with many duplicates, but one element has only 1 copy ? Make a 2-D array temp of size n. This array will store the element and the number of … | |
Re: Check out this link for more information... The problem being discussed here is pretty similar to yours [url]http://www.daniweb.com/forums/thread259931.html[/url] | |
Re: There are 2-3 mistakes in your code 1. You are storing the id is a[0][0], yet when you start storing the marks of the students you start again from a[0][0], the index of the loop on line 23 should start from 1. This mistake is repeated again in the function … | |
Re: Move char* temp to the top of the function sort. Right after the line 67 and make it [code=c] char* temp=0; [/code] Its a good programming practice to initialize all variables to 0. Helps to reduce errors | |
Re: I think there is some problem with your formatting. Write your if else like this [code=c] if( condition ) { // Some code } else { // Some code } [/code] This is how I wrote the while loop in my editor [code=c] while (input != EOF) { if(sec > … | |
Re: Open the file Store the contents of the file, one line at a time into an array- Possibly an array of character pointers Sort the character pointer array | |
Re: Another solution could be something of this sort [code] int main(int argc, char* argv[]) { int i; scanf("%d",&i); if(i<=0) { printf("%d\n",i); // This takes care of 0, -ve and alphabets printf("Invalid Input\n"); } else { printf("%d\n",i); printf("Valid Input\n"); } } [/code] | |
Hello People, I cannot understand how this expression gets evaluated .. 1+~0 From what I know ~ has higher priority . So the expression becomes 1+(~0)= 2 But the answer that I got was 0. I know it is some thing to do with the fact that ~ is right … | |
Re: Try coders for hire, students of fortune. They may be more amenable to your request | |
Re: There are many mistakes in your code 1. When you wanted to remove the number 6, you took the ASCII value of 6 ie 54 but forgot to subtract the ASCII value of 0. Hence your i variable became too big. 2. When you read the number 6 you have … | |
Re: Try Breath First Search. Google for the code, I think you should be able to find it online | |
Hello People... I found this sample code online [code=c ] int main(int argc, char* argv[]) { struct bitfield { signed int a:3; unsigned int b:13; unsigned int c:1; }; struct bitfield bit1={2,14,1}; printf("%d",sizeof(bit1)); return 1; } [/code] I compiled this code on linux with gcc compiler and the output I … | |
Re: [QUOTE=yila;1121214] [code] int check_mat (int mat[N][M], int i, int j) { int r,c; int flag = 1; for(r=i-1; r<i+1 ; r++) { for(c=j-1; c<j+1 ; j++) if(mat[i][j]>mat[r][c]&&IsInside(r,c)) return 1; return 0; } } [/code][/QUOTE] The for loop should be [code] for(r=i-1; [COLOR="Red"]r<=i+1[/COLOR] ; r++) for(c=j-1; [COLOR="Red"]c<=j+1[/COLOR] ; j++) [/code] Otherwise … | |
Re: Can you explain the question more clearly. Also if you can, post the sample input and output | |
Re: There is no restriction as such. You can have the scanf where ever you want | |
| |
Re: Also in the main function. You have to declare variable before using them ..... | |
Re: You do not need the fscanf function. At the point when end of the file is reached, the code will not enter the while loop. Consequently you can do away with the if on line 21 Also you instead of incrementing the count by 1 and then using the mod … | |
[code=c] int main(int argc, char* argv[]) { int a=3,b=2,c; a=a==b==0; printf("%d\n",a); return 1; } [/code] I cannot understand why this code gives 1 as the answer. According to me , this should be the order of evaluation b==0, which gives false & the expression becomes a=a==0 this should again give … | |
Re: I want to see your print function . If it is some thing of this sort [code] for(i=0;i<20;i++) printf("%d\n",arr3[i]); [/code] Then you will get junk characters in the ending. The reason for this is that there are less than 20 numbers in arr 3. | |
Re: [code=c] while(line[k] != '\0') { argv[i] = (char *)malloc(sizeof(char) * 11); /* while(line[k] != ' ') This should be while(line[k]!= ' '&& line[k]!='\0') If you give the command of the type "/bin/ls , your loop keeps on searching till it find the space character */ { argv[i][j] = line[k]; k … | |
Re: There is a mistake on line 8. [code] while(i++<5) // the first value you are dealing with is 1 not 0 result[i]=x[i]-y[i]; [/code] | |
Re: Well from [B]WHAT I KNOW[/B], most modern operating systems do not use SJFS. SJFS is more common in the batch computing days when the user had to explicitly submit his jobs. In such a scenario when the user submitted his job he was required to estimate the run time also … | |
Re: Where exactly are you having a problem ? These are some of the mistakes that I could see 1. Line 8- Dont use typedef in front of the struct 2. Line 29- You have written 4 %d but then you are trying to input 5 things. 3. Line 46- Function … | |
Re: Just a thought ... One of friends has a SONY Walkman phone. He can do simple functions (play/ pause the media player ) by using his cell phone. So that might be a place to start | |
Re: The cin part enables the user to input values which can then be stored in the variables a, b, c. Think of a,b, c as 3 containers. When you declare them [code] int a,b,c; [/code] You are telling the computer that at some point some one will store a value … | |
Hi All, Today I came across a peculiar piece of code. [code] int main(int argc, char* argv[]) { printf("%lf\n",(0.99-0.90-0.09)); } [/code] According to me the output for this code should be 0, but to my surprise when I ran this code the answer that I got was -0.000. I cannot … | |
Re: Quick question , how are you making stars, archers, hearts appear on the screen ? | |
Re: Make an array of the restaurant structures Then sort according to the cost or what ever criteria that you want. You can use any of the common sorting algorithms for this Only remember that each time that you swap, swap the entire structure and not just the cost | |
Re: There is a bug in your program. When you receive a number, you straight divide by 10,000 and the result is stored in an integer. So if the input is 12,123.... This is how your code will process it tthousands= 12,123/10,000 = 1.212 this value will be stored as 1 … | |
Re: [QUOTE=rEhSi_123;1127967]Thanks 'Ancient Dragon', modified code: [CODE] #include<stdio.h> #include<sys/stat.h> #include <sys/stat.h> int main() { int i; char dirname[50]; for(i=0;i<10;i++) { sprintf(dirname,"E:/Visual C/practice/practice/hello/test%d",i); if((mkdir(dirname,00777))==-1) { fprintf(stdout,"error in creating dir\n"); } } } [/CODE] Now my second issue :$ is that I would also like to create files inside each of these folders. … | |
Re: Another option could be to use command line arguments [code= c] int main(int argc, char* argv[]) { // The values can be retrieved from argv. These values can be int, float, string. } [/code] | |
Re: [QUOTE=robinotje;1122811]Ok, I'll do that. Just a question, is this a correct fgets syntax? [CODE]fgets (name[j], 20, stdin);[/CODE] And, why do I always have to use fgets, and not only instead of gets? Do you want me to replace all the scanf with fgets?[/QUOTE] You should avoid scanf as much as … | |
Hello People, Does any one have any practice problem sets for C. I am interviewing for a company tomorrow and they ask lots of "Whats the output ?" kind of questions.. Any help would be appreciated | |
Re: How many child processes do you have to create ? In the sense, you create 1 child process, it does the computation and sends the result back Or the more complicated scenario Each child computes only 1 row of the result matrix and you have to create as many children … | |
Re: [QUOTE=icu222much;1124094]Oh, I think I understand how the functions in the header files work. Now is there a way for me to 'install' the missing code in the library file? I'm not using Windows to run Cygwin. I just Googled Cygwin, and from my understanding Cygwin allows you to run Linux … |
The End.