Fight Stopping AIDS, Let's Do it...


Hi Friends, Let's Stop AIDS, it's increasing like a forest fire... See the page below and learn more about it. www.chulbul.com/aids.htm Let's Know more about stopping AIDS today !! ________________________--- Join the Revolution !! http://www.orkut.com/Community.aspxcmm=27495757...
Posted On: Monday 26th of November 2012 12:48:09 AM Total Views:  324
View Complete with Replies

RELATED TOPICS OF C Language PROGRAMMING LANGUAGE




While loop not stopping for scanf for some reason. please help!

Ok I have a while loop here which contains a switch statement (I have only fleshed out case 1) and functions normally , except for when in case 1 I hit CTRL-D (for EOF, could be CTRL-Z for you). This sends it into an infinite loop and ignores the scanf at the top of the while loop, which it would usually stop at. I do not understand why. Does anyone know Code: #include #include #define MAXLINES 5 int main (void) { int counter=1; float data[MAXLINES]; int array_index=0; int x; int menu_selection = 1; int program_continue = 1; while (program_continue == 1) { printf("This program will perform the following: 1,2,3\n"); printf("select 1,2,3\n"); scanf("%d",&menu_selection); x=1; switch (menu_selection) { case 1: while ( (array_index MAXLINES) printf("\n\nNumber of data lines: %d\n",counter-1); if (counter < MAXLINES) printf("\n\nNumber of data lines: %d\n",counter-2); array_index = 0; break; case 2: printf("continuing\n\n"); break; case 3: printf("goodbye!"); program_continue = 0; break; default: printf("That is not a valid entry.\n"); } } return 0; }
VIEWS ON THIS POST

236

Posted on:

Wednesday 17th October 2012
View Replies!

construct a new type obj failed---how to walk around it...

all. /////////////////////////////////// ////////code sample /////compiling error in vs2005 and gcc3.4 /////////////////////////////////// class CB; CB fn(CB& obj); class CB { protected: CB(){} CB(const CB& ob){} friend CB fn(CB& obj); }; CB fn(CB& obj) { return CB(); } ////////////////////////////////////// template class TA; template TA toolfn(TA& obj); template class TAublic CB { template friend class TA; public: TA(){}; protected: //should be protected or private TA(const CB& ob):CB(ob){} public: friend TA toolfn(TA& obj); }; template TA toolfn(TA& obj) { return TA( fn(obj) ); } int main() { TA f1; TA ret = toolfn(f1);//----->how to make it pass the compiling. /* compiling error: 1.cpp: In function `TA toolfn(TA&) [with T = float]': 1.cpp:52: instantiated from here 1.cpp:36: error: `TA::TA(const CB&) [with T = int]' is protected 1.cpp:46: error: within this context */ return 0; } //////////////////////////////////////////// ///currently, i can using a helper function to walk around this //but it seems that it does not elegant enough... /////////////////////////////// Any hint will be appreciated
VIEWS ON THIS POST

215

Posted on:

Sunday 4th November 2012
View Replies!

New-line fight: Comment -vs- the end of source file

Hi! ISO 14882 international C++ standard says: 2.1/2: ... If a source file that is not empty does not end in a new-line character, or ends in a new-line character immediately preceded by backslash, the behaviour is undefined. 2.7 ... The characters // start a comment, which terminates with the next new-line character. Given those, does the following program have undefined behaviour (Here "#" denotes new-line and "|" marks the end of file): - - - // That's all folks# | - - - In other words, does the comment consume the new-line, leaving no new-line to signify the end of file Cheers! - Risto - --- [ comp.std.c++ is moderated. To submit articles, try just posting with ] [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ] [ --- Please see the FAQ before posting. --- ] [ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
VIEWS ON THIS POST

116

Posted on:

Wednesday 7th November 2012
View Replies!

Reference lets a function to return a variable . But strange things happen :(:(

I wonder how the 'm' value is 10 in the program below . It should be 7. Further, it turns later to 11. Strange. How is it possible Why Need clarification. Any ideas using namespace std; ...
VIEWS ON THIS POST

197

Posted on:

Saturday 10th November 2012
View Replies!