1,494 Posted Topics

Member Avatar for arsnic

In the second example your creating an array of pointers which in your case are 8 bytes.

Member Avatar for arsnic
0
223
Member Avatar for sahil1991

In C structures can hold pointers which can point to functions...So in a way, C structures can hold(point to) functions..

Member Avatar for sahil1991
0
107
Member Avatar for agaba

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 …

Member Avatar for agaba
0
104
Member Avatar for NV43
Member Avatar for NV43
0
147
Member Avatar for usustarr

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 …

Member Avatar for gerard4143
0
184
Member Avatar for Efficience

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]

Member Avatar for Efficience
0
615
Member Avatar for MothershipQ

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 = …

Member Avatar for gerard4143
0
136
Member Avatar for iwanttolearnc
Member Avatar for myk45

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 …

Member Avatar for myk45
0
107
Member Avatar for kuchick32
Member Avatar for beatenbob

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 << …

Member Avatar for WaltP
0
163
Member Avatar for mitrious
Member Avatar for Vv IVIatthew vV

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.

Member Avatar for gerard4143
0
268
Member Avatar for myk45

You'll probably find the answer in here [url]http://www.iecc.com/linker/[/url]

Member Avatar for myk45
0
142
Member Avatar for Daaa

Jeez I tried googling LUA and C++ and found this [url]http://csl.sublevel3.org/lua/[/url]

Member Avatar for Daaa
0
195
Member Avatar for myk45

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 …

Member Avatar for myk45
0
94
Member Avatar for emilyhedgecock
Member Avatar for lukename
Member Avatar for MWE_QUE

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]

Member Avatar for MWE_QUE
0
127
Member Avatar for Beancounter5

Const iterators are used to indicated that the underlying object data members will not change.

Member Avatar for mike_2000_17
0
93
Member Avatar for canadianpanda

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: …

Member Avatar for gerard4143
0
96
Member Avatar for pwp14

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->" …

Member Avatar for gerard4143
0
1K
Member Avatar for ana_1234
Member Avatar for exekiel101
Member Avatar for Ryaether
0
90
Member Avatar for myk45

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 …

Member Avatar for gerard4143
0
88
Member Avatar for BlakTasTic
Member Avatar for WaltP
0
103
Member Avatar for Emaneitron
Member Avatar for jay1648
Member Avatar for myk45
Member Avatar for Eagles36

[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 …

Member Avatar for caut_baia
0
192
Member Avatar for ricardo.crudo

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 …

Member Avatar for ricardo.crudo
0
98
Member Avatar for Agent-of-Chaos

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 …

Member Avatar for gerard4143
0
176
Member Avatar for keeda

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.

Member Avatar for keeda
0
99
Member Avatar for Duece_68

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.

Member Avatar for Duece_68
0
133
Member Avatar for jmcorpse
Member Avatar for Snader

Here's a more complete definition [url]http://msdn.microsoft.com/en-us/library/wt88dxx6%28VS.80%29.aspx[/url]

Member Avatar for N1GHTS
0
130
Member Avatar for aaronmk2

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]

Member Avatar for gerard4143
0
124
Member Avatar for Rayanjaha

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() …

Member Avatar for gerard4143
0
108
Member Avatar for RaoxFaello

This #include <iostream.h> Should be #include <iostream> and cout should be std::cout

Member Avatar for Narue
0
144
Member Avatar for jimbob90

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 …

Member Avatar for jimbob90
0
93
Member Avatar for malvi

That's because you need a separate thread of execution to execute the timers..I would investigate threads.

Member Avatar for malvi
0
125
Member Avatar for ItecKid

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[] …

Member Avatar for abhimanipal
0
804
Member Avatar for varun mca

So you want a function the behaves exactly like clrsrc but isn't clrsrc?

Member Avatar for Adak
0
117
Member Avatar for cogitoergosum18

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};

Member Avatar for VernonDozier
0
304
Member Avatar for Defensor
Member Avatar for Defensor
0
207
Member Avatar for alcx88

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.

Member Avatar for chiwawa10
0
108
Member Avatar for praky

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 …

Member Avatar for praky
0
111
Member Avatar for binoo0324
Member Avatar for TheWolverine

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 …

Member Avatar for TheWolverine
0
302
Member Avatar for harikrishna439
Re: gets

[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...

Member Avatar for gerard4143
0
112

The End.