519 Posted Topics
Re: Pattern matching is not that easy with C. Here is one approach though. If there is some specific pattern to the input then you can check it using if else statements. For example if the input is !1 \ !2 \ !3 You would say if the first char is … | |
Re: There are 2 big mistakes in your program 1. In the printf that you do on line 66 in the client program is causing a seg fault because of parameter mis match. Comment out that line or put the proper parameters 2. The server is waiting for the client to … | |
Re: One way could be to put a if condition before the mod operation. If c is equal to a, dont do the mod operation. Else go ahead and do the mod operation | |
Re: See the objective of the program is to convert from feet to meters. If you use the information that is given in the problem statement ... you see that 10 feet = 12 inches 1 inch= 1/39.37 metres Therefore 10feet= 12*(1/39.37)metres Now the program says that accept the input from … | |
Re: Some thing of this sort if your function is a part of the class definition [code=c] class complex { int x; int y; public : complex(int x, int y) { this->x=x; this->y=y; } void display(complex c) { cout<<c.x<<" "<<c.y<<endl; } }; int main() { complex c1(10,5); c1.display(c1); cin.get(); return 0; … | |
Re: First step will be to read from a file. You can use fread for that. [url]http://irc.essex.ac.uk/www.iota-six.co.uk/c/i2_feof_fgets_fread.asp[/url] Now the 4 bytes that you want to read will be in a character array. The next part is to assign these bytes to form a 4 byte unsigned number. This code will get … | |
Re: I think you will have to use fgets only. | |
Re: [QUOTE=tquiva;1161692]I know that I need to edit somewhere in the skipBlanks function. But I just can't seem to think straight anymore. I was thinking of declaring both \n and ; as characters. then setting them to equal each other. Is that good enough?[/QUOTE] HINT: Make a change in line 70 … | |
Re: In line 20, for one of the conditions you have used the = operator instead of the == operator. = means assignment, where as == means checking for equality. Make the change, compile and run the code. Post what error you are getting Also you might want to google for … | |
Re: [QUOTE=ammarZ;1161465]wow thanks for the cool help! I see what your're saying about subtracting the decimal value of a from the characters so we get like 1, 2, 3 etc for b, c, d, etc.. but I don't get the exact array thing.. like if i do that it'll increment the … | |
Re: [QUOTE=newbiecoder;1160167]I want my code to take two characters and print them, but this code only takes one character, prints it and terminates, can you please tell me what's wrong with it? Thank you. [code=syntax] #include <stdio.h> int main() { char a, b; scanf("%c", &a); scanf("%c", &b); printf("%c %c\n", a,b); return … | |
Re: Make a header file.... Say file1.h. Include all the header file and function declarations is this file. For ex [code=c] #include<stdio.h> #include<string.h> void display(int,int); [/code] Then make a .c file. Put all the function declarations in this file. Include the header file, file1.h in the source code file [code=c] #include … | |
Re: When you declare some thing of the sort [code=c++] int int1; [/code] The compiler gives any arbitrary value to i. This could be 0,1,2,... any value what so ever. As you input a char in response to the second cin, the compiler ignores the value entered by you. Later when … | |
| |
Re: When we multiply 2 matrices, each element of the first row of the first matrix is multiplied with each element of the first column of the second matrix and so on If you can bring one row of the first matrix and one column of the second matrix into the … | |
Re: You might want to try the function gettimeoftheday() PS I am not sure of the arguments | |
Re: I am not sure if this will help but Could it be the case that the int that you are passing to the sleep function is 2 big (the value has over flown ) | |
Hello Everybody, Most of my coding experience is in C. Although I have a background in C++, I know very little of STL and the advanced topics in C++. I came across this code [code=c++] struct g { g():n(0) { } int operator()() { return n++; } int n; }; … | |
Re: You do not need to make different functions for each object. Also your print function is wrong Read up the concepts of objects one more time and you will see that you just need one getter / setter methods per class PS: Change your void main to int main | |
Re: [QUOTE=johndoe444;1120400]The following code fragment from Programming Pearls: [CODE]for i = [0, n) if comlen(a[i], a[i+1]) > maxlen maxlen = comlen(a[i], a[i+1]) maxi = i[/CODE] I am not sure why he called the comlen function twice? Instead he could save the computed value in a temporary and use it to assign … | |
Re: Quick question... How are you supposed to edit the test ? | |
Re: Use an enum. Define all the 13 cards in the enum [code=c] enum card { one=1, two=2, ...... jack=11, queen=12 }; [/code] | |
Re: Your problem is that in the convertToPostfix function your are returning a null stack. Print out the content of the top of the stack just before you return it . The content prints out to be -1 . Consequently in the eval function when you check to see if the … | |
Re: Why is the username and password integer datatypes ? Why have you used cprintf ? Syntax of fwrite is wrong | |
Re: If after resolving the memory issue you are still getting file not found, I will suggest that you take the full path name of the directory | |
Re: Some suggestions 1. Print the contents that you read from the files. In line 133 2. Why are you not considering the value returned by the searchList function- Line 135 3. Also when you call the insert function. What parameters are you sending into the function 4. Google for "insert … | |
Re: One solution could be to replace the '0' by ' ' ie the space character. Is this allowed ? Make a temp array and run a for loop over the alpha array and each time the character is not a (0 or ' ') copy it to the temp array. | |
Re: Quick question. Have you ever included files before ? If no then I think for some reason the header files in the main class are not getting included. That is why, when you call the constructor of the classes defined in those files you are getting an error. | |
Re: Is it some thing of this sort ? Multiply all numbers from 1- n with the number 2 ? If this is it then a simple while loop will suffice | |
Re: If you are having trouble getting started, think on the lines of linked lists. Store each number in 1 node of a linked list. So now the size of the number is not a criterion any more. So for adding just scan both the lists and store the result in … | |
Re: You are passing the arrays by value. The changes made to these arrays will be local to the function. Pass by pointer or use global variables | |
Re: If you have an array of 4 characters, then you have 32 bytes... Will this work for your application ? | |
Re: One suggestion is to remove the data declarations from line 47-48 and put then at the beginning of the function. In C all data declarations have to be at the beginning of the function Put some printfs in your code, narrow down the area where you are getting the problem. … | |
Re: E. Balaguruswami is not a good author. I was reading his C++ book and it has many mistakes. Most notably the use of void main all over the place I would recommend, Let us C, by Yashwant Kanitkar | |
Re: [QUOTE=gerard4143;1148669]Try setting hold[0] = '\0'; Or you may try using buffer[0] == '|'[/QUOTE] buffer[0] means *(buffer + 0) which can be simplified as *(buffer) This is obviously same as *buffer | |
Re: For printing the string the normal way (unreversed) you can use printf("%s\n,name_of_string) | |
Re: Also I would advise clearing out the contents of array1 and array2. As these arrays are local variables they will contain junk values and this could affect your out put | |
Re: fork system call returns the process id of the child and parent. You could use this information | |
Re: Check out this link [url]http://akomaenablog.blogspot.com/2008/03/c-thread-example.html[/url] This maybe of help | |
Re: Can you tell me where did you write the print function ? I wrote the print function in the main after the sort function was called and I was able to print the array elements just fine. | |
Re: One method could be to store all the input numbers in an array. Then find the max and min of this array. If you google you might even get the code for these functions. Your current approach is quite complicated. You dont need so much complication | |
Re: Just take any one skill and become the master of that | |
Re: [QUOTE=Xufyan;1146196]Hello everyone i am new in C language and need some basic help. see this program, [CODE] void main(void) { int a,b; clrscr (); { for (a=1;a<5;a++) { for (b=2;b<6;b++) { printf ("value of a is %d , value of b is %d \n",a,b); b=a+1; a=a++; } } } getch(); … | |
Re: In the main function you call print on line 107.. Before that can you print the entire array of structs ?? | |
Re: Some thing of this sort [code=c] struct test { int x; }t1; t1.x=20 [/code] | |
Re: You could use exit as well. But for this situation it is more appropriate to use the suggestions mentioned above | |
Re: Or you can make n as a global variable Max can be calculated in the function as well |
The End.