519 Posted Topics

Member Avatar for pixelerator

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 …

Member Avatar for pixelerator
0
114
Member Avatar for HBK_100
Member Avatar for jonsca
0
110
Member Avatar for D4n1sD

I am not sure if this will help, but could you over write the data you want to be removed, with spaces ?

Member Avatar for abhimanipal
0
90
Member Avatar for wilsonz91

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

Member Avatar for abhimanipal
0
148
Member Avatar for fux0r

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; …

Member Avatar for abhimanipal
0
115
Member Avatar for konata_89

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 ?

Member Avatar for abhimanipal
0
129
Member Avatar for abhimanipal

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 …

Member Avatar for sheff_cc
0
129
Member Avatar for hwlibra083

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.

Member Avatar for hwlibra083
0
506
Member Avatar for royal33
Member Avatar for abhimanipal
0
90
Member Avatar for Tango2010

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 …

Member Avatar for WaltP
0
162
Member Avatar for johndoe444

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 …

Member Avatar for abhimanipal
0
359
Member Avatar for hwlibra083
Member Avatar for hwlibra083
0
174
Member Avatar for Ajantis
Member Avatar for evilsithgirl

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 …

Member Avatar for abhimanipal
0
135
Member Avatar for COKEDUDE

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]

Member Avatar for Dave Sinkula
0
130
Member Avatar for HBK_100
Re: Help

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 …

Member Avatar for abhimanipal
0
102
Member Avatar for newcuser

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

Member Avatar for mitrmkar
0
406
Member Avatar for tquiva

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 > …

Member Avatar for jonsca
0
124
Member Avatar for newcuser

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

Member Avatar for newcuser
0
2K
Member Avatar for COKEDUDE

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]

Member Avatar for sumitunya
0
2K
Member Avatar for abhimanipal

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 …

Member Avatar for abhimanipal
0
85
Member Avatar for Takarakujin
Member Avatar for sonai4u
Member Avatar for bsudhir6

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 …

Member Avatar for abhimanipal
1
188
Member Avatar for techie929

Try Breath First Search. Google for the code, I think you should be able to find it online

Member Avatar for techie929
1
131
Member Avatar for abhimanipal

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 …

Member Avatar for abhimanipal
1
94
Member Avatar for yila

[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 …

Member Avatar for WaltP
0
179
Member Avatar for johndoe444

Can you explain the question more clearly. Also if you can, post the sample input and output

Member Avatar for WaltP
0
2K
Member Avatar for COKEDUDE

There is no restriction as such. You can have the scanf where ever you want

Member Avatar for WaltP
0
153
Member Avatar for COKEDUDE
Member Avatar for WaltP
0
200
Member Avatar for COKEDUDE

Also in the main function. You have to declare variable before using them .....

Member Avatar for COKEDUDE
0
184
Member Avatar for rico.tee

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 …

Member Avatar for abhimanipal
0
154
Member Avatar for abhimanipal

[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 …

Member Avatar for IsharaComix
0
115
Member Avatar for yila

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.

Member Avatar for yila
0
162
Member Avatar for blerina12

[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 …

Member Avatar for blerina12
0
1K
Member Avatar for piocasino

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]

Member Avatar for WaltP
-1
167
Member Avatar for vishy1618

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 …

Member Avatar for abhimanipal
0
103
Member Avatar for burkeyb

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 …

Member Avatar for jonsca
0
314
Member Avatar for Tara_

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

Member Avatar for mackone
0
122
Member Avatar for sdgz747

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 …

Member Avatar for abhimanipal
0
1K
Member Avatar for abhimanipal

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 …

Member Avatar for abhimanipal
0
99
Member Avatar for datk0m

Quick question , how are you making stars, archers, hearts appear on the screen ?

Member Avatar for whgeiger
0
1K
Member Avatar for DoEds

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

Member Avatar for abhimanipal
0
85
Member Avatar for anjoz

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 …

Member Avatar for abhimanipal
0
76
Member Avatar for rEhSi_123

[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. …

Member Avatar for WaltP
0
2K
Member Avatar for Zaelis

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]

Member Avatar for erantivanisha
0
144
Member Avatar for robinotje

[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 …

Member Avatar for WaltP
0
454
Member Avatar for abhimanipal

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

Member Avatar for Salem
0
100
Member Avatar for PMACLEAN

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 …

Member Avatar for abhimanipal
0
182
Member Avatar for icu222much

[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 …

Member Avatar for icu222much
0
1K

The End.