1,494 Posted Topics
Re: In the second example your creating an array of pointers which in your case are 8 bytes. | |
Re: In C structures can hold pointers which can point to functions...So in a way, C structures can hold(point to) functions.. | |
Re: Please enclose your code with the proper tags [code] #include<iostream> using namespace std; struct BankAccount { int accountNum; double accountBal; double rate; }; int main() { const int ACCOUNT = 5; BankAccount info[ACCOUNT]; int sub; double balTotal = 0; double balAverage; int accountNumber; bool isFound = false; for(sub =0; sub<ACCOUNT … | |
Re: This might move along faster if you posted specific problems.. | |
Re: Please read the click below The exec() family of functions replaces the current process image with a new process image. The functions described in this manual page are front-ends for execve(2). (See the manual page for execve(2) for further details about the replacement of the current process image.) This exert … | |
Re: std::cout is interpreting c as a character string...You know something that ends with a '\0'. If you want the address try this: [code] std::cout<<(void*)c<<" "<<*c<<std::endl; [/code] | |
Re: I didn't notice an if statement.....It could be said that was the only thing that didn't have any errors...What compiler are you using? [code] #include <iostream> #include <cmath> using namespace std; int main (void) { float Height, Radius, BoxHeight, BoxLength, BoxWidth, SiloVolume, BoxVolume, BoxVolumesum = 0, Grainleft; char choice = … | |
| |
Re: Take this out of your header file long addresses[5]; and put it in your main executable... When you compile def.c you create a label called addresses and when you compile mainfile.c you create another label addresses. When you bring both files together for the final executable it fails because addresses … | |
Re: Could you post a brief example of the data files... | |
Re: You can use EOF by pressing Ctrl-Z in Windows or Ctrl-D in Linux....Here's an example [code] #include <iostream> #include <string> int main() { std::string word; std::cout << "Please enter a string of words...EOF to exit" << std::endl; while ( std::cin >> word ) std::cout << "program recieved->" << word << … | |
Re: What is Info record; | |
Re: this 'monday' should be "monday" Strings are enclosed with double quotes not single quotes... If your learning C++ then please get yourself a good book on the subject...Tutorials just don't cut it. | |
Re: You'll probably find the answer in here [url]http://www.iecc.com/linker/[/url] | |
Re: Jeez I tried googling LUA and C++ and found this [url]http://csl.sublevel3.org/lua/[/url] | |
Re: Well how do you define the structure in the second example? Maybe that's a little vague...How do you define the memory layout in the second example? In the first example you have sizeof(int) plus sizeof(struct node *n1) plus padding. In the second example what is the sizeof(struct node)? Its impossible … | |
Re: Can we see the define of the structure? | |
Re: Try using unsigned int...How is ReadBuff defined? | |
Re: Try passing the address of newData... [code] computeFibonacci(&newData); printFibonacci(&newData); [/code] Also this: [code] int computeFibonacci(); int printFibonacci(); [/code] should be: [code] int computeFibonacci(shared_data*); int printFibonacci(shared_data*); [/code] | |
Re: Const iterators are used to indicated that the underlying object data members will not change. | |
Re: If I was writing this this I would strive for simplicity. Have the user enter a value and then have the computer guess 50, the program should respond by indicating higher or lower(or correct). The computer then should take the set above or below and pick a middle value...etc...etc. Example: … | |
Re: You had a few typos in your code...You really should write a small part of the program compile/debug and then move on. [code] #include <iostream> using namespace std; int ScrabbleScore(string word) { int x = 0; int index = 0; while (word[index]) { char ltr = toupper(word[index]); std::cout << "char->" … | |
Re: Can we see the constructors of the class Mixed? | |
Re: Your array is of type int not float. Plus your for statements are wrong. | |
Re: Try this [code] #include <stdio.h> #define j 2 int main(void) { int i; switch (i) { case 1:break; case j:break; default:break; } return 0; } [/code] or [code] #include <stdio.h> enum choices {a, b, c}; int main(void) { int i = 0; fputs("enter a value->", stdout); fscanf(stdin, "%d", &i); switch … | |
| |
Re: How about giving us a hint with some code.... | |
Re: [QUOTE=Eagles36;1348353]I want to know how to create a makefile so that I dont have to type in the files I am linking together. Also is it possible to use a make file which will run two files. I have a fraction.h file and fraction.cxx (implentation file) I have a main.cpp … | |
Re: You need to pass a pointer to a pointer for this to work... Your function should be declared like. [code] void teste(int **p_int) [/code] and you should pass your pointer like [code] teste(&m); [/code] The reasoning is simple really. When you pass your pointer to a function it copies the … | |
Re: You could simplify your program like below: [code] #include <stdio.h> #include <stdlib.h> int main(int argc, char**argv) { char num[10]; FILE *fd; if (!(fd = fopen("testdata", "r"))) { fputs("could not open file!\n", stderr); exit(EXIT_FAILURE); } while (fscanf(fd, "%s", num) != EOF) { fprintf(stdout, "num->%s\n", num); } fclose(fd); exit(EXIT_SUCCESS); } [/code] This … | |
Re: You might to include just a bit more of the code...I have no idea what a obj is. Is it a variable, a reference to a variable, a pointer.... Your error. Did you try casting the void pointer to the appropriate type. | |
Re: You have to, at least, save the original pointer value somewhere so that you can delete and free up the memory...otherwise you create a memory leak. | |
| |
Re: Here's a more complete definition [url]http://msdn.microsoft.com/en-us/library/wt88dxx6%28VS.80%29.aspx[/url] | |
Re: Well the default constructor set degree to zero....the first element of the array coefs. [code] Poly Poly:: operator+(const Poly& p) { Poly temp; for (int i=0; i<degree; i++){//look here...what's degree equal? temp.coefs[i] =coefs[i] + p.coefs[i]; } return temp; } [/code] | |
Re: I really don't know why your using overloaded functions when you really should be using overloaded constructors like below: [code] #include<iostream> class math { public: math(double side1, double side2):area(side1 * side2) {} math(double rad):area(3.14 * rad * rad) {} double getarea() const {return area;} private: double area; }; int main() … | |
Re: This #include <iostream.h> Should be #include <iostream> and cout should be std::cout | |
Re: Try this to start out... [code] #include <string> using namespace std; class car { private: int yearModel; string make; int mpg; public: car(); }; car::car () { yearModel = 0;//zero is a good value to set numeric primary data types mpg = 0;//zero is a good value to set numeric … | |
Re: That's because you need a separate thread of execution to execute the timers..I would investigate threads. | |
Re: Try something like below [code] #include <stdio.h> #include <stdlib.h> #include <string.h> void mycall(char cmd[]) { char *pch = NULL; printf ("%s\n", cmd); /* correctly prints 'ls -l' */ printf ("Before call to strtok\n"); pch = strtok (cmd, " "); printf ("After call to strtok\n"); } int main() { char cmd[] … | |
Re: So you want a function the behaves exactly like clrsrc but isn't clrsrc? | |
Re: You should start my defining x as a string and then compare it to things likes "brown" Please note the double quotes not signal quotes. Or better yet you should create an enumeration. enum Colors {brown, red, yellow,...etc}; | |
Re: First you didn't allocate any memory for the str character pointer.... | |
Re: You have this atoi(argv[i]); Which doesn't save the value generated by the function atoi() Here's the definition of atoi int atoi(const char *nptr); Note it returns an integer and does not change the value of nptr in place. | |
Re: I'm not really sure what you mean...Is it something like below? [code] #include <iostream> int main(int argc, char**argv) { unsigned int i = 0; unsigned int x = 1; int size = sizeof(unsigned int); size *= 8; std::cout<<"ans->"<<x<<std::endl; for (i = 0; i < size; ++i) std::cout<<"ans->"<<(x <<= 1)<<std::endl; return … | |
Re: LNAME is a float....You probably want a string for LNAME. | |
Re: Not absolutely sure what your trying to accomplish here. Is this what your looking for? [code] #include <iostream> class BaseClass { protected: double parameter; }; class DerivedClass : public BaseClass { }; class SecondDerivedClass : public BaseClass { }; class AnotherClass { public: void setParameterOfDerivedClass( BaseClass * baseClass, double parameterValue … | |
Re: [QUOTE=harikrishna439;1337910]I get a warning message while executing a C program containg 'gets'.Is there any way to avoid this.Currently I am using ubuntu OS>[/QUOTE] Yes, use a crappy compiler that doesn't warn you of 'potentially' bad...bad programming practises. And its compiling the program not executing it that generates the warning... |
The End.