2,384 Posted Topics

Member Avatar for vivekgalatage

[QUOTE=vivekgalatage]can anyone please explain me about the concept of namespaces?[/QUOTE]Doing a [url="http://www.google.com/search?q=%22C%2B%2B+namespaces%22"]search[/url] is your best bet for general queries.

Member Avatar for TITAN
0
200
Member Avatar for tahataha

An object is not just a C++ thing associated with a class.[QUOTE][font=Times New Roman][size=3][b]object[/b] region of data storage in the execution environment, the contents of which can represent values[/size][/font][/QUOTE]So [font=Courier New]int[/font]s and pointers and arrays are objects too.

Member Avatar for Chainsaw
0
176
Member Avatar for smithag261

[url="http://users.powernet.co.uk/eton/kandr2/"]http://users.powernet.co.uk/eton/kandr2/[/url]

Member Avatar for brnprasad630
1
97
Member Avatar for Msh84281

>I am wondering what the "using namespace std;" statement is all about. It's a modern, standard C++ (as opposed to old, pre-standard C++) way to use an unadorned [font=Courier New]cout[/font] (for example), which is a member of the [font=Courier New]std namespace[/font]. [url="http://www.cpp-home.com/forum/viewtopic.php?t=252"]Here[/url] are a few more details.

Member Avatar for Dave Sinkula
0
275
Member Avatar for ellisrn

>Can anyone shed any light on this. [quote][font=Times New Roman]The [/font][b][font=Courier-Bold]pow [/b][/font][font=Times New Roman]functions compute [/font][b][font=Courier-Bold]x [/b][/font][font=Times New Roman]raised to the power [/font][b][font=Courier-Bold]y[/b][/font][font=Times New Roman]. A domain error occurs if [/font][b][font=Courier-Bold]x [/b][/font][font=Times New Roman]is finite and negative and [/font][b][font=Courier-Bold]y [/b][/font][font=Times New Roman]is finite and not an integer value. A domain …

Member Avatar for Dave Sinkula
0
2K
Member Avatar for KSGuan

You might try something like this.[code]#include <stdio.h> #include <math.h> [color=red]int[/color] main() { double p,min,max,temp; double pymt[3][100],total[3][100]; int a=0; int n; printf ("Enter loan amt(p): "); scanf ("%lf",&p); printf ("\nKey in minimun interest rate(i): "); scanf ("%lf",&min); printf ("\nKey in maximun interest rate(i): "); scanf ("%lf",&max); printf("%s\t%s\t%s\t%s\n","Monthly payment","Total payment","Interest rate in …

Member Avatar for Dave Sinkula
0
200
Member Avatar for lordofthisworld
Member Avatar for diablo
0
151
Member Avatar for .·)Tusky(·.

[QUOTE=.·)Tusky(·.][b]Well, I put in a number and then it worked not as i planed although.[/b][/QUOTE]In the code you posted, [font=Courier New][color=red]Value[/color][/font] does not have a value (as the error message tried to tell you). [QUOTE=.·)Tusky(·.][b]First i enterd the first, then the second, then the third. Then it just shuts the …

Member Avatar for FireNet
0
494
Member Avatar for Chris Wong

[url="http://www.cppworld.com/forum/index.php?showtopic=474&st=0&#entry3390"]Here is some code[/url] that might get you started or give you ideas. You may want to work with it a bit and then post your latest attempt with any remaining questions.

Member Avatar for FireNet
0
170
Member Avatar for Marilyn_Manson

[QUOTE=meabed][code] #include <iostream> using namespace std; [color=red]int[/color] double Square (double Value); [color=red]int[/color] main () { double Number, SquaredNumber; Number = 5; SquaredNumber = Square (Number); cout << SquaredNumber << endl; return 0; } [color=red]int[/color] double Square (double Value) { double SquareReturn; SquareReturn = Value * Value; return SquareReturn; } [/code][/QUOTE]What …

Member Avatar for Dani
0
172
Member Avatar for coolice

[QUOTE=coolice]BTW : Can I count on the fact that in any windows environment, the absolute maxium for a file or directory name length can not exceed 256 ? [/QUOTE]I might choose to use the standard macro [font=Courier New]FILENAME_MAX[/font].

Member Avatar for Dave Sinkula
0
606
Member Avatar for nufanvandal

I'd be careful with the [font=Courier New]<=[/font], and I wish I'd spent more time looking into the 'Why doesn't this work?', but you may want to try something like this. [code]#include <stdio.h> size_t FillAgeList(int ageList[], size_t size) { size_t i, counter = 0; /* Reads the data from .dat file …

Member Avatar for nufanvandal
0
117
Member Avatar for psk

[QUOTE=psk]can anyone tell me whether ifs function is a member function of ifstream.[code]ifstream ifs( g_pSystemEnvironment->GetTotAlmCountFileName() );[/code]i am not able to understand the code. could anyone help me out of it.[/QUOTE]Here [font=Courier New]ifs[/font] is not a function. It is an object of type [font=Courier New]ifstream[/font]. It is being instantiated using a …

Member Avatar for Dave Sinkula
0
220
Member Avatar for sroberts82

[QUOTE=sroberts82]sorry, I mean in C.[/QUOTE]Check out the [font=Courier New]strtol[/font] example [url="http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1043372399&id=1043284385#opt3"]here[/url]. It can be easily adapted to floating point instead of integer input by instead using [font=Courier New]strtod[/font].

Member Avatar for Dave Sinkula
0
155
Member Avatar for vistatic

Obfuscated for the sake of being too homework-sounding with no work presented.[code]#include <stdio.h> [color=blue]char *f(char*s){char*t=s,*u=t;while(*u)++u;--u;[/color] [color=blue]while(t<u){char x=*t;*t++=*u;*u--=x;}return s;}[/color] int main ( void ) { char text[] = "The quick brown fox"; puts ( text ); puts ( f ( text ) ); return 0; } /* my output The quick …

Member Avatar for meabed
1
361
Member Avatar for abd2

Our friend [font=Courier New][url="http://www.eskimo.com/~scs/C-faq/q12.20.html"]scanf[/url][/font] claims another victim.[code]#include <stdio.h> int main(void) { int x, min, max; printf("Enter val for max and x\n"); scanf("%d%d",&max,&x); min = x > max ? max : x; printf("%d\n",min); return 0; }[/code]

Member Avatar for Dave Sinkula
0
163
Member Avatar for meabed

Max() and Min() don't account for negative numbers. You may want to initialize the Maximum and Minimum to the first element of the list. The summing routine can be done mathematically without a loop.

Member Avatar for Dave Sinkula
0
437
Member Avatar for awmp-jansen

Did you mean to [i]call[/i] the function?[code]case 4:{ clrscr(); affichage2(); /* <===== BUG : Declaration is not allowed here */ }[/code]

Member Avatar for Dave Sinkula
0
129
Member Avatar for Richard Wong

[QUOTE=Richard Wong]Goal: I would like to assign the content of a known function to a function pointer in LINUX environment. Problem: Get segmentation fault when running the function pointer after assignment. Procedure: 1). declare a funtion pointer. [color=red]2). Allocate memory space to the function pointer using the function' malloc'[/color] [color=red]3). …

Member Avatar for Chainsaw
0
82
Member Avatar for phish1429

>What is a vending machine exactly?! Something like [url=http://www.e-vending.com/snack_pop_vending_machines.htm]this[/url].

Member Avatar for Fili
1
2K
Member Avatar for tlee

When you return from your proposed function, the local data goes out of scope. So it is not useful to do it this way. Could you describe what it is you would like to accomplish?

Member Avatar for tlee
0
173
Member Avatar for SeijuroHiko

Ah, yes, [font=Courier New][url="http://www.eskimo.com/~scs/C-faq/q12.20.html"]scanf[/url][/font]. Trouble is almost guaranteed until you decide to quit using it.

Member Avatar for SeijuroHiko
0
302
Member Avatar for mrprimo55

[code]#include <iostream> #include <cstdlib> #include <cctype> int main() { const char text[] = "371", *digit; int value, sum, cube; // Use the text from most significant digit to least significant digit for ( digit = text, sum = 0; *digit; ++digit ) { value = *digit - '0'; cube = …

Member Avatar for Dave Sinkula
2
150
Member Avatar for MaxC

[QUOTE=MaxC]Hello guys, is there a way to declare global variables as [b]float[/b] and then convert them to [b]int[/b] to be used in a function? i.e. [CODE] float num1, num2, result; float Mod(){ num1%num2=result; //Wrong, (%) requires [b]int[/b] type) }[/CODE][/QUOTE]The [font=Courier New][url="http://www.rt.com/man/fmod.3.html"]fmod[/url][/font] function returns the remainder of floating point division.

Member Avatar for ivosetyadi
0
217
Member Avatar for kalachylde
Member Avatar for kalachylde
0
186
Member Avatar for dooda man

If you have conio.h...[code]#include <stdio.h> #include <conio.h> #include <ctype.h> #define ESC 27 #define UP 72 #define LEFT 75 #define RIGHT 77 #define DOWN 80 void foo(const char *prompt) { puts(prompt); for ( ;; ) { int ch = getch(); switch(ch) { case EOF: case ESC: return; case UP: puts("UP"); break; …

Member Avatar for Bleek
0
4K
Member Avatar for dooda man

Something like this?[code]#include <stdio.h> #include <time.h> int main(void) { time_t now, then = time(&now) + 5; if ( now != (time_t)(-1) ) { const char *text[] = {"Hello","World"}; size_t i = 0; for ( ;; ) { printf("\r%s", text[i]); fflush(stdout); if ( ++i >= sizeof text / sizeof *text ) …

Member Avatar for FireNet
0
152
Member Avatar for vio_1960

Try adding a space between int and _stdcall. In the future, try to put your code between [code][/code]. For example, writing the following... [code] #include<windows.h> int _stdcall WinMain(HINSTANCE i, HINSTANCE j, LPSTR k, int l) { MessageBox(0,"Hi","Title",0); return(0); } [/code] ...will produce the following: #include<windows.h> int _stdcall WinMain(HINSTANCE i, HINSTANCE …

Member Avatar for Ashok_beginner
3
690
Member Avatar for phewitt

[url=http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnfiles/html/msdn_serial.asp]Serial Communications in Win32[/url]?

Member Avatar for Dave Sinkula
1
84
Member Avatar for cybergirl

Your only constructor takes two parameters.[code]// Constructor RationalNumbers::RationalNumbers( double num, double den ) { num=numerator; if (den>0) {den=denominator;} }[/code]But you instantiate some objects without supplying parameters.[code] RationalNumbers x; RationalNumbers a; RationalNumbers b;[/code]1. You need to define a constructor that takes no parameters.[code]// Constructor RationalNumbers::RationalNumbers( ) : numerator(0.0), denominator(1.0) {}[/code]2. Or …

Member Avatar for Dave Sinkula
1
410
Member Avatar for TJW

>I am working on trying to get it to work for 3 dimensions + but I would like to see how others implement this. Just keep following the pattern. #include <iostream> void foo(std::size_t x, std::size_t y, std::size_t z) {int q = 0, ***array; // Create and initialize dynamic 3-D "array" …

Member Avatar for TJW
0
316
Member Avatar for FattMarrell

[code]int get_input (int *firstTerm, int *secondTerm, int *thirdTerm, int *fourthTerm, int *fifthTerm, int *sixthTerm); /* ... */ int main (void) { /* ... */ get_input (&fourthTerm, &fifthTerm, &sixthTerm);[/code]If you were the compiler and the programmer told you to expect six arguments and the programmer only gave 3, would you be …

Member Avatar for FattMarrell
1
155
Member Avatar for popo_prince
Member Avatar for prabhu_kar

>How am i supposed to write a code in c which compiles in c but not in c++[code]#include <stdio.h> int main(void) { char new[] = "Compiles in C, not in C++"; puts(new); return 0; }[/code]That is, one way would be to use a C++ (and not C) keyword as a …

Member Avatar for prabhu_kar
0
539

The End.