238 Posted Topics
Re: I don't think so. And if there is some way I would love to know it. :) | |
Re: [QUOTE=raigs;1029871]How to: 1. Buffer output ? 2. Get its size ? 3. Print the buffer ? [CODE]#include <stdio.h> int main(void) { printf("Tons of printf lines\n"); // 1. Somehow buffer the output up until this point printf("The size of the buffer is: %i\n", SIZEOFBUFFER); // 2. Get and print the size … | |
Re: where is the memory allocation for [B]course::classD[/B]. line #32: allocate memory for classD like u did for [B]course::dept[/B] | |
Re: Adding to crazyboy: It can be generalized as follows: [code] expr?expr1:expr2; [/code] MEANS [code] if(expr) expr1; else expr2; [/code] | |
Re: i guess u have not initialized [B]iRowCount[/B] and [B]iNoOfCol[/B]. Also note that [B]iRowCount<=MAX_ROW and iNoOfCol<=MAX_COL[/B]. Otherwise u will get array outofbound error (or seg fault) | |
Re: Below is an idea that u can apply. It is not the complete implementation. U can use this approach may be with some minute modification. [CODE] typedef enum {_INT, _FLOAT, _OTHER} DataType; typedef struct { DataType dataType; union { int intData; float flData; } data; }Data; DataType getType(char *) { … | |
Re: [CODE] name2 = givenLast + “,” + givenFirst; [/CODE] givenLast and givenFirst are not initialized. | |
Re: [QUOTE=Ismailworking;1027992]Hi . i am using C++ editor to write my C code. when i press Ctrl+F9 , the output screen comes and goes without stopping for a while. Please note that i have included "#include<stdio.h>" and i am using "getchar()" function do stop the screen.[/QUOTE] If you are using turbo … | |
Re: Just explore this site a bit. Infix to postfix conversion has been discussed earlier in many threads. | |
Re: 1> 16 posts and yet no code tag 2> U are comparing integer with a node pointer in the following line: [CODE] for(i=1; i<currentNode; i++)/*i : integer, currentNode : a pointer..............................ERROR IN HERE*/ { cout<<i<< getSpatie(currentNode->word)<< currentNode->numTimesAppear<<endl; /*remaining codes*/ [/CODE] I think u are looking for something like [CODE] for(i=1; … | |
Re: use [B]ofstream[/B] class and write to file. | |
Re: u haven't initialized the variables [B]myLineNumbers and temp[/B] and u are trying to operate on it. Initialize them in the constructor as: [CODE] myLineNumbers = new Queue<int>(); temp = new Queue<int>(); [/CODE] | |
Re: -----------sorry double post..............[B]ignore this[/B] | |
Re: [QUOTE=noey699;1028141]i am not sure but it might be friend ostream& operator<< (ostream &, const GrabStuff&); needs a space between operator and << so it would be friend ostream& operator << (ostream &, const GrabStuff&);[/QUOTE] That is not an issue. I dont know why that error is coming though but I … | |
Re: 1> Once the default case is invoked, the flag [B]rightanswer [/B]is set to [B]false[/B] and it is [B]never reset to true [/B]so that the loop ends. 2> U are trying to assign a string using = operator. Use [B]strcpy()[/B]. | |
Re: [B]error 1:[/B] [code] /*you are writting*/ secretType () //default constructor {name = " "; age = 0; weight = 0; height = 0;} /*remember your 'name' var was like: char name[10]*/ /*but you are assigning it a value which is an address to a string of size 2 i.e. " … | |
Re: post the code segment and the error u r getting. | |
Re: code snippet 1: line #24 u are not printing the value. [CODE] /**do it as follows/ cout << "Your number doubled is: " <<number<< endl; [/CODE] code snippet 2: line #4 sysntax error [CODE] /*correct form is*/ class Number{/*() not required*/ } [/CODE] | |
Re: [QUOTE=seoudi;1024119]Create a program that displays a pyramid , square and a triangle using the multiply character “*” as follows: welcome to c++ shape for pyrasmid sqyare trinagle[/QUOTE] In C++ u have so many features available such as: [B]cout[/B], [B]for loop[/B], etc. Use them along with your [B]brain[/B]. That will help … | |
Re: [QUOTE=ankur_;1023933]How can we get the last error occured in linux. suppose there is a connect() func error in that case how to get the error that occured.[/QUOTE] use [B]gdb[/B] to get to the particular statement where the error ocurred. | |
Re: may be u can try this [CODE] char cmd[200]; strcpy(cmd, "ls "); strcat(cmd, pattern); strcat(cmd, " "); strcat(cmd, "> itemlist.tmp"); system(cmd); /*parse the file 'itemlist.tmp' to get all the matching items*/ /*u can use the 'file' command to get info about the item*/ /*or instead of ls u can use … | |
Re: [QUOTE=flyballonfly;1023303] Is there any way to dynamically assign the length of the arrays depending on the input? That was what I was trying to do with the code below. [CODE] fscanf(infile,"%d", &numSegs); char arrOwner[numSegs]; char arrLength[numSegs]; [/CODE][/QUOTE] use malloc() [CODE] char *arrOwner char *arrLength; fscanf(infile,"%d", &numSegs); arrOwner = malloc(numSegs); arrLength … | |
Re: its because of the endianness. Read about Little endian and big endian theory. | |
Re: i think u should do something like [CODE] class cstring { char *str; public: cstring(const char *str) { this->str = (char *)malloc(strlen(str)+1); strcpy(this->str, str); } cstring(const cstring &cs) { this->str = (char *)malloc(strlen(cs.str)+1); strcpy(this->str, cs.str); } bool operator>(const cstring &b) { if(strcmp(str, b.str)>0) return true; return false; } /*some more … | |
Re: it would be like [CODE] class Person { /*members*/ public: void setName(); /*and more*/ }; class Admin:public Person { /*more members*/ }; /*u can use them as*/ Admin adm; adm.setName("Testname"); [/CODE] | |
Re: [QUOTE=agr.pallav;1021369]i would like to know the way we can make user enter a number in a menu reply perhaps so that he doesnt have to press the enter key...........i.e. the program automatically proceeds with the give value and doesnt wait for an enter key to be pressed. its easy in … | |
Re: are u looking for assignments? If so u can try implementing the complex data structures like BST, avl tree, etc. U will will get to learn many thing out of it. | |
Re: compile as c++ fileX.cpp fileA.cpp | |
Re: >Firstly, why is this? It's because u are defining dictionary in more than one place Once in wermz.cpp and once in main.cpp >Secondly, why does it say .bss+0x0 and not the line number? It's the object module which is a binary file and hence it doesn't have a line number | |
Re: [QUOTE=venkat arun;1003964]Hello, I am trying to make a compiler. Don't ask me why because I am making it for fun and experience. I have made a lexical analyser in c++ (I didn't use flex). I now want to make the parser for which I want to use Bison. But I … | |
Re: follow the link [url]https://computing.llnl.gov/tutorials/pthreads/[/url] | |
Re: get the digits and their position and print accordingly. e.g. say 1305. 3 in location 100 hence print "three hundred". proceed accordingly for the rest. [COLOR="Red"]DONT EXPECT READY-MADE CODE HERE[/COLOR] | |
Hi I have joined this community one month ago and have become fan of it. This is the first and only forum where I registered and active since joining. About myself: I am Dharmendra kalita, from Assam, (India). Currently doing as a trainee in GE Healthcare bangalore(India). I have passed … | |
Re: [QUOTE=50701735;1020119]please tell me about some my questions. if (we have a pointer *tmp)-> that my goal is assign that pointer for another pointer ** temp ; so ,how do we assign for right sytax.[/QUOTE] are u asking something like [code] int y; int *p; int **pp; p = &y; pp … | |
Re: This is what I guess it means prev==0 means: Last entry to the bridge was from the NORTH prev==1 means: from SOUTH [CODE] void enter_bridge_north() { num_waiting_north++; //add yourself to the waiting queue while (on_bridge || (prev == 0 && num_waiting_south > 0)) /* *if someone on bridge *OR *previous … | |
Re: use a flag for that as follows [code] #define FALSE 0 #define TRUE 1 void VymazBiele() { int c; int start= TRUE; while ( (c = getchar() ) != EOF ) { if (isspace(c)) { if(start==FALSE) putchar(' '); while ( (c = getchar() ) != EOF && isspace(c)) {} } … | |
Re: U have not initialized your list. In line #17 do [CODE] node *list = NULL; [/CODE] | |
Re: when u include a file in <> brace like follows [CODE] #include <mutex.h> [/CODE] it looks in the include directory. But your file mutex.h is in your current directory. To include such file u have to do it using "" [CODE] #include "mutex.h" [/CODE] | |
Re: start with your code. Post here if u get any issues. | |
Re: do something like: [CODE] typedef struct { int x; int y; }coord; /*store the coordinate of the maze as follows in an array*/ coord maze[]={{1,1},{1,2},{1,3},{1,5},{2,3}, {1,4}}; int mazesize = sizeof(maze)/sizeof(coord);/*hence u won't need to count how many coords are there manually*/ void drawMaze()/*draw the maze*/ { int i; for(i=0;i<mazesize;i++) { … | |
Re: I didn't get what u are trying to do. But let me explain a bit of inheritance [CODE] class Base { /*members*/ }; class Derived:public Base { /*members*/ }; Base *bptr = new Derived(); /*or if u need only base object*/ bptr = new Base(); [/CODE] But using bptr u … | |
Re: write your own functions for validation. e.g. [CODE] bool isnum(char *str) { if(str==NULL) return false; while(*str) { if(!isdigit(*str)) return false; str++; } return true; } [/CODE] | |
Re: the errors are pretty clear i guess. There is nothing that seem to be complicated about the error messages. | |
Re: [CODE] Matrix & operator+(const Matrix &, const Matrix &); [/CODE] this is not the prototype for overloading binary operator. The proper is [CODE] Matrix & operator+(const Matrix &); [/CODE] The other operand for the operation is the calling object. say [CODE] Matrix a, b, c; c = a+b; [/CODE] here … | |
Re: [CODE] /*original function*/ void my_fun(int); /*pointer to function*/ void (*funPtr)(int); /*assigning the function to the pointer*/ funPtr = my_fun; /*calling the function using pointer*/ (*funPtr)(3); //OR funPtr(3); [/CODE] checkout the link [url]http://publications.gbdirect.co.uk/c_book/chapter5/function_pointers.html[/url] | |
Re: [QUOTE=drjay1627;844323] client [code] string s = "Who are you?"; /* transfer data */ write ( sockfd, s, s.size() ); //--compile error nread = read ( sockfd, buf, SIZE ); write ( 1, buf, nread ); close ( sockfd ); exit (0); [/code] there is a compiling error in the client. … | |
Re: regarding increasing efficiency: Every time u invoke getline() method to read something from the file. If the file have say 10,00,000 words u are executing getline() that many time. Now getline() involves file-read operation which is a time consuming task and hence it decreases the efficiency. What u can do … | |
Re: 1> [COLOR="Red"]DO PROPER INDENTATION TO YOUR CODE.[/COLOR] 2> line #7 It should be an assignment(=) statement and not a comparison(==). | |
Re: [code] if(number = 0){} [/code] what do u expect it do do? That is an assignment statement. Read how to compare numbers..... U are doing [code] number = number%16; [/code] u are getting the least significant digit by that and u are loosing the remaining number. U should have done … |
The End.