SEARCH YOUR SOLUTION HERE  

Can't get a program to execute properly.

I'm new to C, coming from perl. Essentially, i'm fairly new to
programming in every way, shape and form.
One project that I continually work on, just to help me get used to
writing, is code that finds primes. This is my first try porting it to
C, and I can't seem to get it to execute properly.
Everything compiles fine, but the program, when executed, will
continue past when I think it should exit. Can anyone point me in the
right direction

/* Prime Number Counter */
/* Attempt Number 1 */

/* Andrew Levenson */
/* 02.07.2007. */

/* Libraries */

#include /* Standard Library */
#include /* For sqrt function */

/* Definitions */


/* Body */

int main()
{
int i = 3, j;
Prime_Test(i, j);
return 1;
};




int Prime_Test(i, j)
{
while(i

Posted On: Monday 5th of November 2012 01:47:30 AM Total Views:  153
View Complete with Replies




Related Messages:

=' token" error, cant figure out whats wrong???" class="" href="http://www.solveerrors.com/forums/13/c-language/help-expected-expression-before-token-error-cant-figure-out-whats-60789" style="color:#333333; font-weight:bold;"> HELP: "expected expression before '>=' token" error, cant figure out whats wrong???   (55 Views)
I've been fixing bugs and errors for hours and now have a raging migraine. I finally got my script from about 12 errors down to one, and I just for the life of me can't figure out what is wrong. I get this error when compiling: it says "error: expected expression before '>=' token. Any idea what is going on here Thank you. P.S. no I'm not in the class, I'm using the open course material to learn programming and following along on my own. Code: #include #include int main(void) {int MonthNum;long long Pennies; /* ask user for total days in the month */do { printf("Enter total days in the month: \n"); MonthNum = GetInt();}while (MonthNum = 32); /* ask user for starting amount of pennies */do { printf("Starting number of pennies on Day 1: \n"); Pennies = GetInt();}while( Pennies
503 c syntax error at end of input please help ..i cant spot any error out there ..   (174 Views)
Always start resolving errors from the beginning of the list, because the later ones may be a result of a previous error. C reads the file top-down. Also make sure you compile with your warnings turned all the way up. Here are the errors I get: Code: $ gcc -Wall -g -std=c99 report.c -o report report.c:32: error: expected =, ,, ;, asm or __attribute__ before * token report.c: In function main: report.c:54: warning: implicit declaration of function printf report.c:54: warning: incompatible implicit declaration of built-in function printf report.c:70: warning: implicit declaration of function scanf report.c:70: warning: incompatible implicit declaration of built-in function scanf report.c: In function Student_Records_Maintenance: report.c:101: warning: incompatible implicit declaration of built-in function printf report.c:116: warning: incompatible implicit declaration of built-in function scanf report.c: In function Add: report.c:140: error: StudentRecord undeclared (first use in this function) report.c:140: error: (Each undeclared identifier is reported only once report.c:140: error: for each function it appears in.) report.c:140: warning: implicit declaration of function fopen report.c:145: warning: implicit declaration of function prinft report.c:153: warning: incompatible implicit declaration of built-in function printf report.c:162: warning: incompatible implicit declaration of built-in function scanf report.c:163: warning: implicit declaration of function fflush report.c:163: error: stdin undeclared (first use in this function) report.c:198: warning: implicit declaration of function fprintf report.c:198: warning: incompatible implicit declaration of built-in function fprintf report.c:207: warning: implicit declaration of function fclose report.c:214: warning: implicit declaration of function _sleep report.c:215: warning: incompatible implicit declaration of built-in function printf report.c:217: warning: incompatible implicit declaration of built-in function printf report.c: In function Modify: report.c:229: error: StudentRecord undeclared (first use in this function) report.c:234: warning: incompatible implicit declaration of built-in function printf report.c:238: warning: implicit declaration of function fscanf report.c:238: warning: incompatible implicit declaration of built-in function fscanf report.c:238: error: EOF undeclared (first use in this function) report.c:242: error: stdin undeclared (first use in this function) report.c:250: warning: incompatible implicit declaration of built-in function printf report.c:251: warning: incompatible implicit declaration of built-in function scanf report.c:318: warning: unknown conversion type character [ in format report.c:318: warning: too many arguments for format report.c:324: warning: incompatible implicit declaration of built-in function fprintf report.c: In function Delete: report.c:363: warning: incompatible implicit declaration of built-in function fscanf report.c: In function Process_Examination_Report: report.c:403: warning: missing braces around initializer report.c:403: warning: (near initialization for size[0]) report.c: In function Generate_Bill: report.c:505: error: FILE undeclared (first use in this function) report.c:505: error: BILL undeclared (first use in this function) report.c:557: warning: incompatible implicit declaration of built-in function fprintf report.c: In function Process_Examination_Report: report.c:570: error: expected declaration or statement at end of input report.c:570: error: expected declaration or statement at end of input report.c:404: warning: unused variable sum report.c:404: warning: unused variable GPA report.c: In function Modify: report.c:570: error: expected declaration or statement at end of input report.c: In function Student_Records_Maintenance: report.c:570: error: expected declaration or statement at end of input Many of those will go away simply by #including . Then you need to read up on how to properly use printf/scanf and the format specifiers. Googling some tutorials would be a good idea. As for the error you mentioned at end of input, you seem to be missing a closing }. This would be much more apparent if you had and used an editor with an auto-indent feature.
just started c programming and i cant get my head around it :/   (127 Views)
ive been reading books tutorials etc... but i just cant get my head around how i would start or even structure the program i am so confused the program i am trying to make is as follows: write a program that converts an amount of money specified into pennies into the old UK monetary units of pounds, shillings and pence. There are 12 pennies to the shilling, and 20 shillings to the pound. You will also need to make sure that only an integer number of pounds and shillings and pence are printed. So, if the input value is 241 (pennies) then your program should print out: 241 pennies is 1 pound, 0 shillings and 1 penny or for 42 pennies: 42 pennies is 0 pounds, 3 shillings and 6 pence so how would i go about understanding and coding a program like this any help would really be apprecitaed
Need help, cant get program to quit a loop   (137 Views)
here is my program, it does what its suppose to, display a banner of the letters a user inputs, but it doesn't break the loop, and will keep printing out the statements, where have I gone wrong Code: #include #include int main() { char string[4]; int count=0; int space=32; char a='a';char b='b';char c='c';char d='d';char e='e';char f='f';char g='g';char h='h';char i='i'; char j='j';char k='k';char l='l';char m='m';char n='n';char o='o';char p='p';char q='q';char r='r'; char s='s';char t='t';char u='u';char v='v';char w='w';char x='x';char y='y';char z='z'; printf("Please Input 4 Capital Letters\n"); scanf("%s", &string[4]); do switch (string[4]) { for(count=0;count>=4;count++); case 'A':printf("%d,%d,%c,%d,%d,\n",space,space,a,space,space); printf("%c,%c,%c,%c,%c,\n",space,a,space,a,space); printf("%c,%c,%c,%c,%c,\n",space,a,a,a,space); printf("%c,%c,%c,%c,%c,\n",space,a,space,space,a,space); printf("%c,%c,%c,%c,%c,\n",a,space,space,space,space,a);break; case 'B':printf("%c,%c,%c,%c,%c,\n",b,b,b,b,b); printf("%c,%c,%c,%c,%c,\n",b,space,space,space,b); printf("%c,%c,%c,%c,%c,\n",b,b,b,b,b); printf("%c,%c,%c,%c,%c,\n",b,space,space,space,b); printf("%c,%c,%c,%c,%c,\n",b,b,b,b,b);break; case 'C':printf("%c,%c,%c,%c,%c,\n",space,c,c,c,c); printf("%c,%c,%c,%c,%c,\n",c,space,space,space,space); printf("%c,%c,%c,%c,%c,\n",c,space,space,space,space); printf("%c,%c,%c,%c,%c,\n",c,space,space,space,space); printf("%c,%c,%c,%c,%c,\n",space,c,c,c,c);break; case 'D':printf("%c,%c,%c,%c,%c,\n",d,d,d,d,space); printf("%c,%c,%c,%c,%c,\n",d,space,space,space,d); printf("%c,%c,%c,%c,%c,\n",d,space,space,space,d); printf("%c,%c,%c,%c,%c,\n",d,space,space,space,d); printf("%c,%c,%c,%c,%c,\n",d,d,d,d,space);break; case 'E':printf("%c,%c,%c,%c,%c,\n",e,e,e,e,e); printf("%c,%c,%c,%c,%c,\n",e,space,space,space,space); printf("%c,%c,%c,%c,%c,\n",e,e,e,e,e); printf("%c,%c,%c,%c,%c,\n",e,space,space,space,space); printf("%c,%c,%c,%c,%c,\n",e,e,e,e,e);break; case 'F':printf("%c,%c,%c,%c,%c,\n",f,f,f,f,f); printf("%c,%c,%c,%c,%c,\n",f,space,space,space,space); printf("%c,%c,%c,%c,%c,\n",f,f,f,f,f); printf("%c,%c,%c,%c,%c,\n",f,space,space,space,space); printf("%c,%c,%c,%c,%c,\n",f,space,space,space,space);break; case 'G':printf("%c,%c,%c,%c,%c,\n",space,g,g,g,g); printf("%c,%c,%c,%c,%c,\n",g,space,space,space,space); printf("%c,%c,%c,%c,%c,\n",g,space,space,g,g); printf("%c,%c,%c,%c,%c,\n",g,space,space,space,g); printf("%c,%c,%c,%c,%c,\n",space,g,space,space,g);break; case 'H':printf("%c,%c,%c,%c,%c,\n",h,space,space,space,h); printf("%c,%c,%c,%c,%c,\n",h,space,space,space,h); printf("%c,%c,%c,%c,%c,\n",h,h,h,h,h); printf("%c,%c,%c,%c,%c,\n",h,space,space,space,h); printf("%c,%c,%c,%c,%c,\n",h,space,space,space,h);break; case 'I':printf("%c,%c,%c,%c,%c,\n",i,i,i,i,i); printf("%c,%c,%c,%c,%c,\n",space,space,i,space,space); printf("%c,%c,%c,%c,%c,\n",space,space,i,space,space); printf("%c,%c,%c,%c,%c,\n",space,space,i,space,space); printf("%c,%c,%c,%c,%c,\n",i,i,i,i,i);break; case 'J':printf("%c,%c,%c,%c,%c,\n",j,j,j,j,j); printf("%c,%c,%c,%c,%c,\n",space,space,space,space,j); printf("%c,%c,%c,%c,%c,\n",space,space,space,space,j); printf("%c,%c,%c,%c,%c,\n",space,space,j,space,j); printf("%c,%c,%c,%c,%c,\n",space,space,j,j,j);break; case 'K':printf("%c,%c,%c,%c,%c,\n",k,space,space,space,k); printf("%c,%c,%c,%c,%c,\n",k,space,space,k,space); printf("%c,%c,%c,%c,%c,\n",k,k,space,space,space); printf("%c,%c,%c,%c,%c,\n",k,space,k,space,space); printf("%c,%c,%c,%c,%c,\n",k,space,space,space,k);break; case 'L':printf("%c,%c,%c,%c,%c,\n",l,space,space,space,space); printf("%c,%c,%c,%c,%c,\n",l,space,space,space,space); printf("%c,%c,%c,%c,%c,\n",l,space,space,space,space); printf("%c,%c,%c,%c,%c,\n",l,space,space,space,space); printf("%c,%c,%c,%c,%c,\n",l,l,l,l,l);break; case 'M':printf("%c,%c,%c,%c,%c,\n",m,space,m,space,m); printf("%c,%c,%c,%c,%c,\n",m,m,space,m,m); printf("%c,%c,%c,%c,%c,\n",m,space,m,space,space); printf("%c,%c,%c,%c,%c,\n",m,space,space,space,m); printf("%c,%c,%c,%c,%c,\n",m,space,space,space,m);break; case 'N':printf("%c,%c,%c,%c,%c,\n",n,space,space,space,n); printf("%c,%c,%c,%c,%c,\n",n,n,space,space,n); printf("%c,%c,%c,%c,%c,\n",n,space,n,space,n); printf("%c,%c,%c,%c,%c,\n",n,space,n,space,n); printf("%c,%c,%c,%c,%c,\n",n,space,space,n,n);break; case 'O':printf("%c,%c,%c,%c,%c,\n",o,o,o,o,o); printf("%c,%c,%c,%c,%c,\n",o,space,space,space,o); printf("%c,%c,%c,%c,%c,\n",o,space,space,space,o); printf("%c,%c,%c,%c,%c,\n",o,space,space,space,o); printf("%c,%c,%c,%c,%c,\n",o,o,o,o,o);break; case 'P':printf("%c,%c,%c,%c,%c,\n",p,p,p,p,p); printf("%c,%c,%c,%c,%c,\n",p,space,space,space,p); printf("%c,%c,%c,%c,%c,\n",p,p,p,p,p); printf("%c,%c,%c,%c,%c,\n",p,space,space,space,space); printf("%c,%c,%c,%c,%c,\n",p,space,space,space,space);break; case 'Q':printf("%c,%c,%c,%c,%c,\n",space,q,q,q,space); printf("%c,%c,%c,%c,%c,\n",q,space,space,space,q); printf("%c,%c,%c,%c,%c,\n",space,q,q,q,space); printf("%c,%c,%c,%c,%c,\n",space,space,space,q,space); printf("%c,%c,%c,%c,%c,\n",space,space,space,q,q);break; case 'R':printf("%c,%c,%c,%c,%c,\n",r,r,r,r,r); printf("%c,%c,%c,%c,%c,\n",r,space,space,space,r); printf("%c,%c,%c,%c,%c,\n",r,r,r,r,r); printf("%c,%c,%c,%c,%c,\n",r,space,space,r,space); printf("%c,%c,%c,%c,%c,\n",r,space,space,space,r);break; case 'S':printf("%c,%c,%c,%c,%c,\n",s,s,s,s,s); printf("%c,%c,%c,%c,%c,\n",s,space,space,space,space); printf("%c,%c,%c,%c,%c,\n",s,s,s,s,s); printf("%c,%c,%c,%c,%c,\n",space,space,space,space,s); printf("%c,%c,%c,%c,%c,\n",s,s,s,s,s);break; case 'T':printf("%c,%c,%c,%c,%c,\n",t,t,t,t,t); printf("%c,%c,%c,%c,%c,\n",space,space,t,space,space); printf("%c,%c,%c,%c,%c,\n",space,space,t,space,space); printf("%c,%c,%c,%c,%c,\n",space,space,t,space,space); printf("%c,%c,%c,%c,%c,\n",space,space,t,space,space);break; case 'U':printf("%c,%c,%c,%c,%c,\n",u,space,space,space,u); printf("%c,%c,%c,%c,%c,\n",u,space,space,space,u); printf("%c,%c,%c,%c,%c,\n",u,space,space,space,u); printf("%c,%c,%c,%c,%c,\n",u,space,space,space,u); printf("%c,%c,%c,%c,%c,\n",u,u,u,u,u);break; case 'V':printf("%c,%c,%c,%c,%c,\n",v,space,space,space,v); printf("%c,%c,%c,%c,%c,\n",space,v,space,v,space); printf("%c,%c,%c,%c,%c,\n",space,v,space,v,space); printf("%c,%c,%c,%c,%c,\n",space,v,space,v,space); printf("%c,%c,%c,%c,%c,\n",space,space,v,space,space);break; case 'W':printf("%c,%c,%c,%c,%c,\n",w,space,w,space,w); printf("%c,%c,%c,%c,%c,\n",w,space,w,space,w); printf("%c,%c,%c,%c,%c,\n",w,space,w,space,w); printf("%c,%c,%c,%c,%c,\n",w,w,w,w,w); printf("%c,%c,%c,%c,%c,\n",w,w,w,w,w);break; case 'X':printf("%c,%c,%c,%c,%c,\n",x,space,space,space,x); printf("%c,%c,%c,%c,%c,\n",b,space,space,space,b); printf("%c,%c,%c,%c,%c,\n",space,space,x,space,space); printf("%c,%c,%c,%c,%c,\n",space,x,space,x,space); printf("%c,%c,%c,%c,%c,\n",x,space,space,space,x);break; case 'Y':printf("%c,%c,%c,%c,%c,\n",y,space,space,space,y); printf("%c,%c,%c,%c,%c,\n",space,y,space,y,space); printf("%c,%c,%c,%c,%c,\n",space,space,y,space,space); printf("%c,%c,%c,%c,%c,\n",space,space,y,space,space); printf("%c,%c,%c,%c,%c,\n",space,space,y,space,space);break; case 'Z':printf("%c,%c,%c,%c,%c,\n",z,z,z,z,z); printf("%c,%c,%c,%c,%c,\n",space,z,space,space,space); printf("%c,%c,%c,%c,%c,\n",space,space,z,space,space); printf("%c,%c,%c,%c,%c,\n",space,space,space,z,space); printf("%c,%c,%c,%c,%c,\n",z,z,z,z,z);break; default :printf("out of range, please enter a letter\n"); }while (count=4;count++); Try adding break in default case. oops, that break only out of switch. I suggest removed the do/while loop and learning how to use the for loop outside of the switch statement. Tim S., Actually here's a variation on that which may be more useful: Code: #include #define LETTER_HEIGHT 5 const char *Alphabet[26][5] = { { " a ", " a a ", " aaa ", " a a ", " a a " }, { "bbbbb", "b b", "bbbb ", "b b", "bbbbb" } }; int main(void) { int i; for (i=0; i < LETTER_HEIGHT; i++) printf("%s\n", Alphabet[0][i]); for (i=0; i < LETTER_HEIGHT; i++) printf("%s\n", Alphabet[1][i]); return 0; } With this one, you could get rid of the switch completely by simply using toupper() on the input, then subtracting 65 (the ASCII value for 'A') from each input character to get the array reference from *Alphabet[][]. Ascii Table - ASCII character codes and html, octal, hex and decimal chart conversion
cant get output   (137 Views)
program doesnot hav syntax error but doesnot give its specified output might be some logical error cant find it. Code: /* program to store runtime data in two multidimentional array and match them if same word occurs b/w them it is omitted in second and remaining is printed again */ #include #include int storear(char s[],int flag); void match(char *s1[],char *s2[]); int storear(char s[10],int flag) /*STORE STRINGS IN ARRAY*/ { int i; char c; for(i=0;i
break statement not within loop or switch error, cant figure out the problem, help!   (153 Views)
so this is my code, it's suppose to locate the first occurrence of value and return its position and return -1 if not found. i dont understand why it's giving me this error, please help! Code: int list_search( itemType value, List L ) { if (L->count==0) { printf("Warning: empty array!\n"); } else { int i; for (i=0; icount; ++i);{ if (L->data[i]==value) { return i+1; break; } } return -1; } } , And another issue; you don't return anything for an "empty array".
Something very difficult could have been made significantly easier?   (141 Views)
*** A lot of learners have to deal with problems similar to this. As this, like many newsgroups, deals with a fairly high content ratio of spammed advertising, I decided I'd like to share my ANSI-C learner- related situations with other learners; just because I/they/we are learners, doesn't mean we're stupid -- do try not to be like the people who respond to me signalling that there's simply "too much to read", as I wouldn't expect a coder ever to find that to be a problem (but that so many coders, texters, emailers, clickers, and Oscar(r/tm) winners do have problems reading or writing more than a few characters and typically need your help if you know how to make CPU-containing devices work). So: don't bust your chrome just trying to prove that there shouldn't be any problems (any other pointers read) *** Dear Telnet/SSH client authors, I am contacting authors of telnet clients with ANSI terminal emulation for their feedback regarding a change I have suggested to the ANSI terminal control codes. This day I wrote the ANSI a letter detailing the proposed additional control code, and am waiting for their response. In the meantime I am hoping to learn from the authors of terminal clients whether they would be interested in implementing the hypothetical change if it were standardized, or even if it weren't. I haven't used your products, as I'm usually using PuTTY-SSH or even windows telnet. I choose these products because they are allowed by the public servers that I typically am sessioning on. I have sent seperate letters to the authors of PuTTY and to Microsoft's... research section for the Americas, in regards to their own clients which I use. My letter to ANSI is attached, and I'm hoping you'll read it and respond. My contact information is at the bottom of the attached letter. Any details concerning the actual implementation, such as which control characters will be used and under which existing terminal modes, I have left for future development, as I figure that ANSI will in their own right determine how it's best done. If they respond that they expect me to be more thorough in my explanation of how it can or should be implemented, then I will have to draft a letter to them with all the details worked out, including terminal state queries and switches for ON and OFF, etc. (of course, if ANSI doesn't respond or respond in the negative, this is still something I would like to see implemented -- in a completely standardized fashion, as it wouldn't do any good being implemented in various ways by various client authors). It is because of this same need for standardization that I can't just "write my own client" to solve the problem. I know that some clients authors have probably chosen to use a macro or re-mnemonic system that allows the end-user to define or redefine some behaviours of the client in response to various control codes, but this is, again, not a truly standardized solution, as it requires the specific use of that client and the instrumentality of reassigning the mnemonic or macro. I will send any important responses or developments to any interested authors when they are received or drafted. Thank you, and have a good day. --- --- cut here --- --- email to: psa@ansi.org ANSI, I have been struggling with some programming troubles lately in the use of ANSI-C. It seems that there is no standardized function to read single keypresses from the device driver STDIN, as the presumption is of a command-line mode that requires the carriage-return keypress before placing any character data into the buffer to be read. There are several methods for getting around this, but none are very portable. A library called "ncurses" offers this keypress functionality but at the expense of horribly twisting the format of the terminal screen, which is not a very logical or useful trade-off, especially as normal use of the "ncurses" library makes it difficult to use ANSI-x3.64 terminal controls without errors cropping up: the "ncurses"-provided "printw" function chooses to display the control codes literally rather than allow their results to be produced by the terminal, and the use of "printf" to get around this results in a slow buildup of errors somewhere invsible to the user. "Ncurses" library has several other problems, such as the sudden involuntary display of characters when the "getch()" function (which is used to get the single keypress) is called -- these characters would normally not be displayed until a different, screen-related function, "refresh()" is called. For the user who simply wants a portable method of retrieving a single keypress in a normally command-line environment, but who does not want to sacrifice normal operative control of their terminal screen, they are faced with recreating their own "getch()"-like function which might not be (probably is not) portable. I decided to crawl through the specifications relating to the terminal controls offered by ANSI-x3.64. Though it is an old spec, it is still very widely used to this day. Though not every control code is emulated in terminal programs, the old terminals are for the most part emulated in the most necessary means; cursor controls, color controls, scrolling, and other very simple terminal means. I was hoping to find a solution somewhere in the terminal controls. It seemed to me an easy assumption that this problem, of getting a single keypress in a command-line environment, was a very old problem that had been solved many ways, albeit not portably, for quite some time, and that this necessitated something portable, and that x3.64 would be the best place to look for this portable solution. There was at one time a widely-implemented solution, the use of key redefinition which allows the host to redefine which character or series or characters will be sent with any given keypress from the terminal. However it was seen in the 90s that this feature was going largely unused and had been forgotten only to be rediscovered by budding hackers who began planting "ANSI Bombs" in their colorful terminal artworks, which would redefine the spacebar to format drive C in DOS, and so on. Today, the keyboard redefinition feature is largely removed from many terminal emulators, and pkzip for DOS still ships with an executable that will remove the emulation of the redefinition control from ANSI.SYS entirely. Keyboard redefinition would have been a decent way around the command-line environment; a host could have sent various queries to a terminal in order to find out the current states of various keys, and then remapped keys important to the specific application so that they sent their usual character plus a carriage return. When the application was being closed, the host could have remapped the keys to their original states. This would allow for single keypress functioning across any of various platforms. Were this still implementable, the archives of comp.lang.faq and language-related newsgroups and so on would not today be plagued with requests for a portable answer to this problem, and the inevitable "noob!" responses. As it turns out, searching for anyone else who's had a similar idea, I am pretty much the only one who misses keyboard redefinition, and apparently am the only one who thought that ANSI-x3.64 had provided fairly well for us in the original regard even if the solution had not been implemented. However, I believe that the eventual widespread banning of keyboard redefinition functionality was almost inevitable, as it was simply too wide of a security hole not to be exploited. As the ANSI.SYS era was seemingly on its way out, the function was simply over-written instead of rewritten (I say "seemingly" because lo and behold, for all the times people who say there is no more EGA, no more 8bit, and no more ANSI terminal, there are the times when they sit down and use any number of applications in their telnet or SSH session that are colored and coordinated by way of ANSI-x3.64 terminal control codes). I crawled some more and could not find another suitable solution, so I thought one up. I would like to see it standardized, fanfared if possible to attract attention to its new existence, and hopefully implemented by the authors of terminal programs, especially those that are widespread in common use due to being packaged with operating systems. What I would like to see is one of the existing "unused" control codes in the ANSI terminal control code structure, currently in x3.64, that places the terminal in "keypress mode". I know this sounds very narrow and otherwise not useful, but there is available space in the terminal controls, and this feature practically begs on its own for admission into the bitwidth. I am sure some enterprising others may come up with other uses for this mode, but its original purpose would be as follows: a command from the host to the terminal to enter this mode, and when in this mode for the terminal to send, along with the character data which it normally would for any given keypress, immediately thereafter a carriage return, which is simply one more character. There are some modes that already exist in ANSI-x3.64 whose descriptions bear some resemblance to this, but closer study of them reveals that they are not quite it. If ANSI could have provided this solution quite some time ago, it would have been really something, though my friend says it would have had to come closer to the time of 1985-1994, rebuking my exhorting that it would practically have revolutionised the terminal BBS and textmode game days throughout the 90s. Today there are still numerous textmode applications being built which rely on all sorts of external programs that behave in various and erractic ways and which do not interact well. If ANSI were to standardize this new terminal mode, though it does not emulate any given terminal of the past, they would be providing a great deal of help to programmers everywhere, who would no longer be required to rely on external programs in order to have this function available through terminals. It would also allow ANSI to provide this single-keypress ability without having to put it into the language of C itself, as the problems of doing so there are almost as numerous as the solutions that programmers have come up with so far. Thank you very much for ANSI-x3.64, for ANSI-C, and for listening. -- Gabriel Arthur Petrie Lansing, Michigan (USA) eyenot@gmail.com eyenot@hotmail.com --- --- cut --- --- -- "Audacity, always audacity." * * * * * * FIRST RESPONSE * * * * * * Hi Gabriel, We are not aware of any of our customers required the extra features. Best
operator+ cant be constant   (135 Views)
Hi all, Jesse Liberty writes: "Note that the String class provides the operator+. The designer of the Employee class has blocked access to the operator+ being called on Employee objects by declaring that all the string accessors, such as GetFirstName(), return a constant reference. Because operator+ is not (and can't be) a const function (it changes the object it is called on), attempting to write the following will cause a compile-time error: String buffer = Edie.GetFirstName() + Edie.GetLastName();" (the String class he refers to is a custom String class coded for demonstration purposes) I agree that the line will cause a compile time error because operator + isn't defined as a const method: constString.operator+(anotherConstString)
what libraries/classes to use for precision significant calculations?   (159 Views)
, I'm doing some calculations with great amount of precisions required. Can somebody please suggest some suitable libraries or classes to use
Where to get the best (Microsoft?) C++ certification?   (208 Views)
Hi I have good C++ knowledge, but would like to get perfect by study and then get a certification. What is best (online/mail) certication Where can I do tests for it (online/mail) What is the most respectable certification Does it have to be Microsoft certification How about Visual C++, object oriented programming certifications
Use of operator T const& to get a reference to self   (166 Views)
Given the following program: #include class FG { public: explicit FG( std::locale const& l ) : myLoc( &l ) {} template< typename F > operator F const&() const { return get< F >( *myLoc, &std::use_facet ) ; } private: std::locale const* myLoc ; template< typename F > F const& get( std::locale const& l, F const& (*f)( std::locale const& ) ) const { return (*f)( l ) ; } } ; FG getF( std::locale const& l ) { return FG( l ) ; } void f() { std::ctype< char > const& ct = getF( std::locale() ) ; } G++ (4.1.0) instantates the template operator F const& to get the const reference needed to call the copy constructor (which of course fails to compile, since use_facet is not legal). Providing a non-template: operator FG const&() const { return *this ; } solves the problem, but is g++ correct here I would have expected the temporary "FG( l )" to bind directly to the const reference of the (compiler generated) copy constructor. Or maybe my question is: is this intentional Given 8.5.3/5, "[...]If the initializer expression [...]-- has a class type [it does] and can be implicitly converted to an lvalue of type "cv3 T3", where "cv1 T1" is reference-compatible with "cv3 T3" [...] then [...] the reference is bound to the lvalue result of the conversion [...]" But it doesn't seem at all natural to have a user defined conversion called for a copy. -- James Kanze (GABI Software) mailto:james.kanze Conseils en informatique oriente objet/ Beratung in objektorientierter Datenverarbeitung 9 place Smard, 78210 St.-Cyr-l'cole, France, +33 (0)1 30 23 00 34 --- [ 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 ]
Of getline(cin,...), Ctrl+D and infinite loops   (152 Views)
Here is a small program. It's meant to keep reading lines from the stdin till someone types the (really cute) string "manchu". In that case it breaks out of the loop and the program terminates. /////////////////////////////////// #include #include using namespace std; int main() { string str; char ch; while ( cin ) { cin.clear(); cin.ignore( cin.rdbuf()->in_avail() ); getline( cin, str, '\n'); if ( str == "manchu" ) break; if ( cin.eof() || cin.fail() ) { cin.clear(); } } return 0; } I am compiling this with gcc 3.3.1 on Solaris 9 SPARC, and with gcc 3.2.3 on RHEL 3. Now here is the crux. I wanted that if the user just typed "Ctrl+D", it should clear the eof and fail bits and continue the loop looking for more input. It does this nicely on Linux but goes into an infinite loop on Solaris sparc, repeatedly encountering EOF. I am guessing that this is a wrong piece of code and somehow it is working in one case, and not in the other case. And hoping that someone actually points out where I am going wrong. -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ]
How to get (re)started?   (140 Views)
I'm a C/C++ old-timer. My last C++ was writing the book Learn C++ Today! (Don't blame me for the title.) One of my best books, by the way. Heartily recommended to all who think there's a future in MS-DOS programming. Before the world went totally GUI, I went totally Java, so I don't know basics like how to launch a window, how to populate a form, etc. I have a project now that I plan to do in C. Can someone recommend a good (re)starting point I'm using Linux (KDE), but would like to support Gnome and Windows, too.
How to get the weekday?   (132 Views)
If input date in format "yyyymmdd", how to determinate the weekday i.e If input 20070228, which function can return "Wed" Thank you..
fstream getline   (164 Views)
I'm trying to do line-at-a-time command interpreter input under eCos using an fstream for a serial port (/dev/tty1). The fstream has a 256-byte filebuf, and it's doing 256-byte fread() calls underneath. However, even though fread() gets a short read from the underlying device when I hit Enter, it goes back and reads more, until it gets the full 256 bytes--which perversely seems to be what the C standard requires it to do. Is getline() generally supposed to work as one would expect on interactive devices Is one expected to do a setvbuf on it, either to disable buffering, or to supply a one-character buffer I've tried both of these under eCos, and neither works, but I wouldn't be a bit surprised if eCos's implementation of fstreams, or for that matter the C stdio library, is buggy. -- Ciao, Paul D. DeRocco Paul mailtoderocco@ix.netcom.com [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ]
Problems with cin (already tried getline)   (147 Views)
. I have some problems with cin. Here's the code: http://rafb.net/p/GhK3AU65.html If you press '6', and 'enter', it will have to ask for another insert of a string. However, in this case, it goes straight without waiting for input... any ideas
[C++] can't get the full string when using c_str()   (173 Views)
, I've got one here I just don't understand. The problem isn't with SQL syntax or anything related to the database system, but I wanted to give that info so that you would understand why the string is formatted like so. Ok, I have code that ultimately is trying to build a string that looks like this: INSERT INTO table (col1, col2, col3, col4, col5) VALUES ('data col1', 2, 3, '1/3/2007', 'Misc data' ); Now, in my code, the string is built like this: // assume the below function is a class member with data members // std::string insStr // std:stringstream int2char void BuildInsString( std::string& d1, int d2, int d3, std::string& d4 ) { insStr += "INSERT INTO table (col1, col2, col3, col4, col5) VALUES ("; insStr += "'"; insStr += d1; insStr += "', "; int2char
How to get FILE structure for standard output ?   (145 Views)
Hi , I have following dumping function and use it for dumping data to files: int Dump(FILE* file, char* string) Everything goes ok, but this time I need to dump my data into standard output, standard error, ect. Where can I get the proper pointer to FILE structure or how should I initialize this structure correctly Thanx N.
Trying to pass a variable outside of while(! user.eof()){ user.getline(playerName,100); cout   (186 Views)
here is my problem void resumeGame(userData & loadInfo) { cout
How can I get the input stream in commandline application ?   (253 Views)
Subject: How can I get the input stream in commandline application Hi ! I have to get the input stream in my win32 commandline application. Using another words, I want to catch content of input stream file given like this: myapp.exe < data.txt How can I do it