257 Posted Topics
Re: i think the error is the missing [B];[/B] at the end of the class declaration in the header file. [CODE]class Prog { public: void ReadList(int Array[], int N); void Avgs (int Array[], int N, int &Ave, int &aveP, int &AveN); int Large (int Array[], int N); void Display(int Array[], int … | |
Re: >>Then I want to make graphics, ı mean ı want to show moves in Chess Board , are there any source code of this ? Well, there are many Graphic libraries available. Question is, how good do you want them to look? Do you want the Chess pieces to be … | |
Re: Declare a structure as follows: [CODE] struct read_file { char name[100]; int age; } var; fscanf(fp, "%d = %s", &(var.age), var.name); [/CODE] | |
Re: Well, you can try this: 1) Check if it is an Uppercase letter.(Using the ASCII value) 2) If it is, add 32 to it.(convert it to lower case) [URL="http://www.asciitable.com/"]Ascii Table[/URL] | |
Re: Paste the code, of whatever you have tried. We can help you build on that. Well, here is a hint: Let the number be N rev_num = rev_num * 10 + (N % 10) N /= 10 You need to do this till N becomes 0. | |
Re: >>If each number entered by the user is 3.7E+38 / 10, then the average of those ten numbers should never exceed 3.7E+38 correct? Yes, it is correct. Could you elaborate a little more? What problem are you facing? | |
Re: Hint: Use [CODE]cout << a + 1[/CODE] in the inner for loop. | |
Re: Well, you can't use cout to do that. You will have to use other libraries. Here is one: [url]http://qt.nokia.com/products/[/url] | |
Re: Well, the function is basically allocating memory to a bunch of pointers. It can be shown like this: [CODE] [....] means allocate memory to a pointer. ptr1 = [.....] ptr2 = [.....] ptr3 = [.....] ptr4 = [.....] This is done by for(i=MIN;i<row;i++) { arr[i]=malloc(col*sizeof*arr); if(!arr) { printf("\nMemory unavailable"); exit(EXIT_FAILURE); … | |
Re: It depends what type of image you want to read. Reading a bmp file is pretty simple. [URL="http://en.wikipedia.org/wiki/BMP_file_format"]Here[/URL] is the bmp format. | |
Re: @OP Is this what you mean? Use a visited[] array to mark the ones that have already been generated. [CODE]int visited[100]; // to mark visited ones. Let all of the values be 0 initially. int count = 0; // Now, lets try to store 10 unique numbers between 0-99 while … | |
Re: Well, you can try this: 1) Count the number of lines in the file 2) Do this: [CODE] rand_no = rand() % count; // where count is the no. of lines in the line.[/CODE] 3) Now, use a loop to iterate to that line. PS:[URL="http://www.cplusplus.com/reference/clibrary/cstdlib/rand/"]rand()[/URL] | |
Re: Well, you can try this method: This involves extra space though. Algorithm: 1) Extract words into a buffer( i have used a 2D array) 2) Mark indices 3) Swap indices. 4) Print as per indices, so that the words will be swapped. [CODE] char *arr = "hello world bye world"; … | |
Re: Well, i guess you can use threads. But you might have to make sure you make them synchronized. i have never tried doing it, but i guess you can, using threads. | |
Re: [CODE] #include <stdio.h> void value(int *Matrix,int a, int b); int main(void) { int Row1 = 0, Col1 = 0, Row2 = 0, Col2 = 0; int Matrix1[10][10]; // Here. int Matrix2[10][10]; printf("This is matrix multiplication program"); printf("\nEnter the dimensions of two array "); scanf("%d %d %d %d", &Row1, &Col1, &Row2, … | |
Re: [CODE]printf(" a . b = %4.1f\n", dot(a, b));[/CODE] Did you miss this out? i checked the output. i got 1.0 for c.b. That is correct right? | |
Re: Well, you can try 2 things: 1) Ask the user for how many products he wants. 2) Let entering -1 for a product be the end of the product list. ie: 1) [CODE] while ( salesPerson != -1 ) { cout << "Enter the number of products"; cin >> productCount; … | |
Re: OK, you can try this: 1) Reverse the string 2) Reverse each word in it eg: Hello World 1) dlroW olleH --> i guess you have done this part. Now, reverse each word in it For this, try this: [CODE]for (i = 0 to length(string)) { while (string[pos] != SPACE) … | |
Re: Could you elaborate a little more? >> in which even no.s print Do you mean you want to print the even numbers in the array? Also, paste the code you have already written. | |
Re: @OP You could try using scanf() in this way: [CODE] /* enter eqation */ scanf("%dx %c %dx %c %d", &v1, &v2, &v3) ;[/CODE] eg: 1x + 2x - 3 But in this case, you cannot give -x in the beginning as in your example, you will need to enter 1x. … | |
Re: Well you can use Qt. [url]http://qt.nokia.com/products/[/url] You can configure VS for Qt. If it is just a single push button, i suggest you create a small rectangular box with a label on it that says "Press" or something like that. i mean would you like to use an entire framework/library … | |
Hello, im trying to implement a generic double linked list, and i have added just one function(insert). But im getting some errors. Here is the code: [CODE]#include <iostream> #include <cstdio> #include <string> using namespace std; template <typename T> class doubleList { private: struct Node { T info; Node *leftPtr; Node … | |
Re: >>I've tried to Link both of them on Visual studio and Code::Blocks with no succes. Both libraries you mentioned are pretty good. i have tried using ARToolKit (not on my machine, my friend's machine, on VS 2010) and there was no problem. Could you elaborate what exactly is the problem? | |
Re: There you go: i have written where i made the change [CODE]# include <stdio.h> # define MAX 100 int main(void) { int array[MAX],i,n; //printf("\n Enter Array Size: ",MAX); scanf("%d", &n); //Allows user to choose Array Size for(i = 0; i < n; i++) { printf("\n Enter %d value: ",i+1); scanf("\n%d", … | |
Re: Refer Programming Windows by Charles Petzold. An excellent book, and it also has a lot of examples. In fact, there is a sample code too, for drawing text in a Window. i haven't done much Windows programming myself, but i just referred the book. You can use [B]DrawText()[/B] function. | |
Re: Adding to what MosaicFuneral has suggested, you can try this, if this is what you are looking for [CODE] float val = 2.0; // make an unsigned char pointer point to the beginning, then extract all bytes unsigned char *ptr = (unsigned char *)&val; // first byte unsigned char p … | |
Re: OK, from what i understand, you basically need 5 recursive functions: 1) This returns the count. [CODE]compute_digits_count(num) { if (num equals 0) return 0; return 1 + compute_digits_count(num / 10) }[/CODE] 2) The above code finds the number of digits. For the sum, this hint would be enough: Hint: Digits … | |
Re: [CODE]float orientation;[/CODE] So, orientation is a floating point variable. So, how come this : [CODE]orientation.x[/CODE] Or, did you intend it to be [CODE]rot.x[/CODE] instead? | |
Re: Could you paste the code here? Also, i guess you are referring to VS 6.0 . [URL="http://en.wikipedia.org/wiki/Visual_C%2B%2B"]These[/URL] are the versions of VC++. Are you using VC++ 6.0? | |
Re: Where are you looping through the matrix and checking if it is a magic square? [CODE]// calculate sum of 1st row for (i = 0 to cols) { sum += mat[0][i]; } // now check if all other rows and cols sum upto the same for (i = 1 to … | |
Re: Check [URL="http://eternallyconfuzzled.com/tuts/datastructures/jsw_tut_linklist.aspx"]This [/URL]out. Is that is what you're looking for? | |
Re: Ok, you can use a recursive method for this. 1) Write a function to print each row, i.e say row number 3 is: 1 2 3 2 1 The function to do this can be done like this: Let max be a global variable, indicating the maximum number of each … | |
Re: Well, since you mentioned array, you can try this: int num2[10], num1; /* Input num1 here */ ..... /* Multiplication part */ for(cont = i - 1, n = 0; cont >= 0; cont--, n++) { res = res + ( (num1 * num2[cont]) * pow(10, n) ); } This … | |
Re: In the first case, i think the problem is with this: sizeof("\n") = 2. not 1 because, "\n" is a string, and is terminated by a "\0". [CODE]write(fd, "\n", 1);[/CODE] has to be [CODE]write(fd, "\n", 2);[/CODE] i think this might fix it. | |
Re: @dubery Hope this helps: [CODE] int a[10]; /* array to hold the numbers of the permutation */ void perm(int level) { int i; if (level == 3) { print the array } else { for (i = 0; i < 3; i++) { a[level] = i; perm(level + 1); } … | |
Re: Hmm, Qt is really good. But since you are asking for C, Gtk would be a good choice [url]http://www.gtk.org/[/url] PS: These are libraries or frameworks, not compilers. | |
Re: What are you trying to do? The x is incremented. But you are not using it anywhere. It would help if you explain what you are trying to do. | |
Re: The conversion formula is: C = (F - 32) * (5 / 9) and F = (C * 9 / 5) + 32 So, [CODE]for (x=0; x <= 100; x++) { printf("%d %d", x, CF(x)); } int CF(int C) { /* calculate the formula here and return the needed value. … | |
Re: i have marked the places where i have made changes:- [CODE] #include <stdafx.h> #include <stdio.h> #include <string.h> #include <ctype.h> int main( void ) { char text[ 3 ][ 100 ]; char search; char *searchPtr; int count = 0; int i; int k; printf( "Enter two lines of text:\n"); for ( … | |
Re: According to what i understood, you have a huge cube and you need to initialise the smaller cubes inside it, with their (x, y, z). Am i right? A more elaborate explanation would be helpful. | |
Re: @OP Adding to the above suggestion, 1)Fundamentals of Data Structures in C++ by Ellis Horowitz , Sartaj Sahni, Dinesh Mehta 2)Data Structures Using C by Aaron M. Tenenbaum im not sure about the first book, the second one is pretty good. | |
Re: >>1. why we needed **p in the function AllocString? The function is receiving an address of a pointer. What is a pointer? It holds the address of a variable. So, say you have [CODE]int i; int *ptr = &i; /* Pointer to an integer */ int **ptr1 = &ptr; /* … | |
Re: You might want to try this: [URL="http://msdn.microsoft.com/en-us/library/dd743680%28VS.85%29.aspx"]http://msdn.microsoft.com/en-us/library/dd743680%28VS.85%29.aspx[/URL] | |
Hello, i needed suggestions regarding the book "Art of Computer Programming" by Donald E Knuth. im an undergraduate Computer Science student. i would like to know more about the book before i buy it. So, any reviews? Reviews as to how the Math in it is(i heard there are a … | |
Re: [CODE] #include <stdio.h> #include <stdlib.h> #include <ctype.h> #include <string.h> #include <time.h> int main() { char array1[][10]= {"sam", "ben", "sally", "molly", "jake", "samuel", "table", "chair", "computer", "mouse"}; char answer; char input; int r1=0; int r2=0; int length=0; int loop=0; int loop2=0; int score=0; srand (time(NULL)); for (loop=0;loop!=10;loop++) { r1 = rand() … | |
Re: im guessing the input file what you are using has the numbers not separated from each other. This was the contents of the file when i executed: 10.0 20.0 This works fine, so i guess the problem was, you had not separated by spaces. | |
Re: Ok, all you need is the use of a graphic library(i would suggest OpenGL) to render the pixels. [url]http://www.talisman.org/opengl-1.1/Reference/glDrawPixels.html[/url] All you need is to render these pixels after reading it into a buffer. [CODE] fread(buff, 1, 800 * 600 * 3, fp); // read into buffer (i assumed an 800 … | |
Re: @OP >>"is it really getting saved in a text file and how can i view it?" Open the file :) Since you have not specified the path explicitly, it generally gets created in the same directory as the source file or sometimes the executable. Just open it and check it … | |
|
The End.