238 Posted Topics
Re: in line #11 u are declaring the method [B]set_values()[/B] which takes two characters as parameters. But in line #28 U are calling the same function passing a string. Try out yourself how to solve it. Read how to store a string and operations on it. | |
Re: [QUOTE=Reprise;1012867] [code=C] FILE* fd; fd=fopen("salesbin.bin","wb"); fwrite((struct salesRecord*) sales, sizeof(struct salesRecord), 196, fd); fclose(fd); [/code] [/QUOTE] are u using fread() for reading your data. Its obvious that when u open your file using some editor u wont see the exact values u are storing. U can see the characters because a … | |
Re: check line #6: [CODE]char encrpyt(int , char);[/CODE] the parameters are int and char. In line #20 [CODE] char encrypt(int codekey, char stringydoo[80] ) /* Encrypt Header line */ [/CODE] now the params are one int and a char []. correct the prototype at line #6. | |
Re: [QUOTE=popcorn99;1012464] 1) The program malfunctions weirdly if the user does not enter a number. [/QUOTE] its because scanf() is expecting u to enter some integer numbers. If u want it to work for any input then better take your input as string, validate it and get its' integer value to … | |
Re: [CODE] error: changes meaning of 'Allocator' from 'class Allocator<OctNode<NodeData, Real> >' [/CODE] what is the OctNode class. If it's a template class u have to write it as so [CODE] class Octree{ public: static Allocator<OctNode<NodeData, Real>> Allocator; [/CODE] | |
Re: u are not resetting the variables [B][I]i[/I][/B] and [B][I]k[/I][/B] to zero and due to which the condition [CODE] if(i==0) [/CODE] and [CODE] if(k==0) [/CODE] fails after u have completely printed one character range. | |
Re: [QUOTE=daviddoria;1011703]Does any one have any clues for me? Dave[/QUOTE] are u compiling it as [code] c++ Example.cpp graph.cpp [/code] If not then do it like that. | |
Re: [QUOTE=yozo;1011613]Heya, When I run this code, it spits out the minimum value 200, when I want it to spit out the minimum value from the function. Any pointers? [CODE] #define _CRT_SECURE_NO_DEPRECATE #include <stdio.h> // You can assume no inputs will exceed these values: #define MAX_BOXES 50 #define MAX_PARCELS 50 int … | |
Re: the same solution in a simpler way [CODE] #include<iostream> #include<stack> using namespace std; bool evalPostfix(char *postfix, double &result, char *error); bool isop(char c); int main() { char post[100]; char err[100]; cout<<"Enter postfix expr:"; cin>>post; double result; if(evalPostfix(post, result, err)) cout<<"result="<<result<<endl; else cout<<err<<endl; return 0; } bool evalPostfix(char *postfix, double &result, … | |
Re: [QUOTE=sonaxi;1010482]------------------------------------------------------------------------ Item No. Cost Quantity Amount ------------------------------------------------------------------------ 1 40.00 1 40.00 2 150.00 10 1500.00 3 2000.00 20 40000.00 4 10.00 10 100.00 ---------------------------------------------------------------------- Total 41640.00 i want to print this in c++ help me..i m new in programming...[/QUOTE] start with cout. | |
Re: for compilation use c++ main.cpp roster.cpp | |
Re: [QUOTE=killerqb;1011192]I'm creating an expression tree that reads in postfix notation and converts it and prints it out into infix notation. I was wondering how would I go about correctly distributing parentheses and balancing them properly.[/QUOTE] normal expression: a+b-(c*d) postfix: ab+cd*- input | stack values ----------------------------------- a | a (push a) … | |
Re: give it a try with the following [CODE] string[i]^=(char)255; [/CODE] | |
Re: may be u can do it as [CODE] void ConcreteVisitorA::VisitElement(Element e) { int numNodes = e.GetNumNodes(); int numAttrs = e.GetNumAttrs(); cout << "Visitor has found " << numNodes << " noes\n"; Visitor tempV;/*set all the necessary data members*/ e.nodeVec[0]->Accept(tempV); } [/CODE] | |
Re: I test ran your code and got the following output: Enter the maze's dimensions separated by a comma. Format x,y: 3 5 cout << maze[][].*Wall; in LoadMaze() 0,0 stores 1 1 1 1 0,1 stores 1 1 1 1 0,2 stores 1 1 1 1 1,0 stores 1 1 1 … | |
Re: [QUOTE=surfer2009;1009132]please help for this code. if anyone have it please send me. thanks[/QUOTE] IMPORTANT: 1. this is not a code repository. 2. We help those who show some effort. | |
hi I want to retrieve the contents (including the tables) from a .doc file using C in linux. If I can get the representation of the .doc file, then also I can proceed. I have though done that but it has some bugs because I am using a logic which … | |
Re: By default the access specifier is private in a class and hence u are not able to access the ginfo() and pinfo() method of the class STD1. U have to set them as public. Do [CODE] public: void ginfo(); void pinfo(); [/CODE] | |
Re: [QUOTE=allensmith;1007477]I have to manipulate strings so that, we need to check if a string needs to be combined with another string. Need to use a library function for this. Suppose, we have S1. This is an apple s2. apple is sweet so, the combined line should be: This is an … | |
Re: [QUOTE=jakesee;1009094]hi, just want to ask, is it possible to restrict friend acess to a single class member function only? in other words, if class A grant class B friend access to class A member function, then class B can call that class A function. *note: this is suppose to be … | |
Re: [QUOTE=katamole;1009040]A quick question: I have been writing a small program to simply read a file and send to cout. [CODE]#include <iostream> #include <fstream> using namespace std; int main() { char ch; ifstream in_stream; in_stream.open("self.cpp"); while(!in_stream.eof()) { cout << ch; in_stream.get(ch); } in_stream.close(); return 0; } [/CODE] This works ok, except … | |
Re: [QUOTE=bobsta;1009034] [CODE] fourMatrix(fourVector &i, fourVector &j, fourVector &k, fourVector &l): i(i),j(j),k(k),l(l){ } fourMatrix(fourVector i, fourVector j, fourVector k, fourVector l): i(i),j(j),k(k),l(l){ [/CODE] [/QUOTE] those two are the same prototype.U can declare only one of them. Let me explain: Say u have two functions: [CODE] void test(int x); void test(int &x); … | |
Re: [QUOTE=stevencolbert86;1008705]How do you create a program in c++ to find the closest pair of points in a 2D plane recursively?[/QUOTE] Its not about c++. Its about getting an algorithm first. The implementing language is not a very big deal if u have a good algorithm. First get an algorithm. If … | |
Re: [QUOTE=froggy1976;1007945] [code] void TicTacToe::postMove(int row, int col, char value){ if (theBoard[row][col] == '-'){ theBoard[row][col] = value; } else cout << "Space is already taken, please choose a different one." << endl; [/code] [/QUOTE] make the return type of the above function as bool. Return false if the space is already … | |
Re: [QUOTE=red999;1006477] [CODE] strcpy(array[daysize]->appts[0]->subject, strtok(NULL,"/,:\n"));[/CODE] [/QUOTE] avoid something like that. It might give segentation fault if there is no more tokens (strtok() returns NULL). Make a check before doing any operation on the string pointed to by the address returned by the strtok() function. [CODE] char *c = strtok(NULL, "/,:\n"); if(c!=NULL) … | |
Re: see the syntax of "if" statement in C. u r doing [CODE] if(condition) statement; statement; [/CODE] which is actually [CODE] if(condition) statement;/*will execute depending on the condition*/ statement;/*will always execute*/ [/CODE] do it as [CODE] if(condition) { statement; statement; }/*use curly brace*/ [/CODE] | |
Re: [QUOTE=programmingnova;1007987] [CODE] void getdata(int &major, string &lastname, float &credits, float &gpa, float &tuition, int &senior, int &freshman, int &sophomore, int &junior, float &totaltuition, float &totalcredits, float &totalgpa, float &maxgpa, float &maxmathgpa, float &maxcisgpa, string &lastname, string &newlastname, string &mathlastname, string &cislastname); [/CODE] [/QUOTE] Use a struct variable to store the … | |
Re: declare your [B]p[/B] as [B]static[/B] in the [I]show_sllist()[/I] method | |
Re: [QUOTE=complexcodes;1006836] [code] int operator+::LargeDigit(const VeryLongInt &digit) { return digit.intz+=digit.intz; }[/code] [/QUOTE] it should be [CODE] int LargeDigit::operator +(const LargeDigit &digit)//SEE THE SYNTAX properly { /*your code*/ }[/CODE] where did u get that [B]VeryLongInt[/B] ........????? U are overloading the operator + for the class [B]LargeDigit[/B] right ...!!! | |
Re: hi, i run your program and got the following output: 230.12we are in the loopwe are in the loopwe are in the loopwe are in the loop4 with input file as: "input.txt": 23 .12 3 35 3 2 1 4 3 2 3 67 1 4 | |
Re: i guess u r looking for something like [CODE] struct myData { int data; bool valid; } vector<myData> setList; [/CODE] | |
Re: [CODE] result = sqrt((sqr(c))-(sqr(b))); [/CODE] if c>b then u will have [B]sqrt(-ve number)[/B]. U cant calculate sqrt for a negative number. | |
Re: [QUOTE=gtey;1006828]am trying to make a timer circuit with the help of 89c52 micro controller. I have one assembly language program, but the programming kit supports only to C language. I want to translate assembly program to C program so that I can use it for the above mentioned micro controller. … | |
Re: DO the following at the very begining: 1) push a '(' to the stack. 2) append ')' to the inputted expression string 3) now proceed with your remaining code. This should solve your problem. | |
Re: u can do that by keeping a counter or as follows: [CODE] class mymap { map<.....> m; int maxsize=5;//say /*if(m.size()<maxsize) then only do more addition to it. Else dont.*/ } [/CODE] | |
Re: prob 1. Remove all the elements of the queue and push it in the stack. Now pop from the stack one element at a time and add it to the new queue until the stack is empty. Now return the new queue. prob 2. the answer is there in your … | |
Re: [CODE] while(1) { printf("Select from the following operation:"); printf("1]Addtion"); printf("2]Subtraction"); printf("3]EXIT"); /*new statement*/ printf("Enter your choice here:"); scanf("%i",&z); if(z==3) break; switch(z) { case 1: /*your code*/ /*more cases*/ } } [/CODE] | |
![]() | Re: try it as follows [CODE] Window *w=(Window *)it->second; /*or (Window *)(it->second) if the former gives error*/ w->getTitle(); [/CODE] ![]() |
Re: [QUOTE=bobrien314;1005175]IS it possible to have text in the command line delimited by "" rather than white space?[/QUOTE] i guess nothing's impossible.... U just have to parse the input on your own rather than using the inbuilt stuffs | |
Re: look at the following [CODE] if( tmp1->surname > tmp2->surname) [/CODE] thats not a way for comparing two strings. U r comparing the address of the string instead. use [B]strcmp()[/B] for that purpose | |
Re: [QUOTE=ayan2587;1005269]hi Guyz... need some help here... i want to input an integer but it can be either in hexadecimal form or in integer form. the problem is that i would like to store that input in that particular form and separate all hexadecimal values in to an array. for ex: … | |
Re: dont go for dynamic memory allocation if u really need efficiency and u know the range (approx) of the elements u r going to have. u can declare your array as [CODE] #define MAXTRANSITION 100 int pIntId[MAXTRANSITION]; int pTransistion[MAXTRANSITION]; [/CODE] throw an exception when the no. of transitions exceeds MAXTRANSITION. | |
Re: make the following correction in main() [CODE]for(i=0;i<n;i++) { scanf("%d",&array[i]); /*& added*/ } [/CODE] | |
Re: [QUOTE=gauri_phatak_87;1004356]Hello everyone, I have to write a code to creat a pseudo assembler..I have an input file from which i read the assembly instructions from there i get the register numbers ...i have to convert that into machine code..i.e binary form... Now my problem is that i can find the … | |
Re: [QUOTE=Ashishinani1756;1003868]Hi! I m getting difficulty in pointers can u help ?[/QUOTE] follow the link [url]http://www.exforsys.com/tutorials/c-language/c-pointers.html[/url] | |
Re: [CODE] BST_t * infixtree(char* infix) { char *i,*p; char n1; BST_t *temp,*r,*l,*root,*t; i = &infix[0]; while(*i) { // skip spaces while(*i == ' ' || *i == '\t' && *i != '\0') { i++; } if( isdigit(*i) || isalpha(*i)) { while( isdigit(*i) || isalpha(*i))/*add (&&*i)*****/ { push_exp(*i); i++; } /*add … | |
Re: the compiler generates a machine code which is dependant on the platform where the compiler is installed. Read about how Java attained platform independance. That will give a brief idea of why C is not like that. | |
Re: if u want need second highest score, 3rd highest n so on, the best thing is just sort the scores. If u need only 1st, 2nd and 3rd u can keep two more variables like 'score'. Do it in similar way as u did for the highest score. | |
Re: use c++ -o test TEST.cpp TestDefine.cpp for compiling your code. | |
Re: [QUOTE=anandi ilu;1003823]Can anyone help me to get the program code for printing the transpose of a matrix as output......pls help as soon as possible......[/QUOTE] > we r not here to do ur homework......... > U have to give some effort and then we can help........ Try out the problem yourself. … |
The End.