scanf

search for more blogs here

 

"C Programming Newbie ITT once more.." posted by ~Ray
Posted on 2008-01-02 00:18:53

We have teamed up with to offer Free UK Mainland Delivery to all of our regular readers. To qualify all you be to do is and alter to our community! More details can be open. Hey guys,It's been a month since I last needed back up for C Programming and I've managed to get through the class so far without support! I've just started a few new questions though and I must ask for some help. The question asks me to:Write a complete C schedule that sums a grade of values using for looping statement. The first integer readwith scanf specifies the number of values remaining to be entered. Your program should read only one determine eachtime scanf is executed. The following is an example enter/output dialogue (5. 1.23. -2.62. -7.66,92.65 and 25.68 are the user input). I undergo created a program that does this but the problem is that I must press enter after each value is entered. The question requires that there be a space between each determine after the first integer. The end result is as shown: #consider <stdio h>int main() { int x count; go sum = 0 y; printf("gratify register the be of values to sum: "); scanf("%d". &x); printf("Please enter the %d values separated by lay to be summed: " x); for (count = 0; count < x; ascertain++) {scanf("%f". &y); sum = sum + y; } printf("Sum is %f" sum); scanf("%d"); return 0; } As always there are many ways to skin a cat personally try using gets Wierd question. The way I would do it is get the whole line using gets and loop through the string using scanf creating the variables and using lay as the delimiter. wish this helps but I am unsure of what the question is asking for. I actually realised that my solution works just fine for the requirements Sadly my next question is regarding the following:A fix number is a positive integer quantity that is evenly divisible (without a remainder) only by 1 or by itself. For example. 7 is a prime number bus 6 is not. Write a complete C program to reason and arrange the in therange of 1 and n where n is the user input. An example run of the program is shown below (100 is the user enter). Hints: 1. One is a prime by definition. 2. A number x is a prime if the remainders of x/2 x/3. ... x/(x-1) are ALLnonzero (using remainder operator (%)). Answer: LanParty UT NF590 SLI-M2R/G | Athlon 64 X2 5200+ @ | AC Freezer64 Pro2GB Corsair DDR2-6400 | Hiper 580W Type-M250GB Barracuda ES | Point Of View 8800GTXLogitech.

Forex Groups - Tips on Trading

Related article:
http://forums.bit-tech.net/showthread.php?t=142015

comments | Add comment | Report as Spam


"Please check this coding for me!" posted by ~Ray
Posted on 2007-12-09 14:21:29

I was asked to create verbally a simple billing system. So this is the code i can go up with. I know there are some mistakes there but i can't figure what is it. Please analyse it for me and correct it. /*Updating a Series of Customer Accounts(simplified billing system)*/#include <stdio h>void readinput(int i)cancel writeoutput(int i)struct go out{int month;int day;int year;};struct account{char name[40];char street[40];char city[40];int acct_no; go previous_balance;go current_payment;float new_balance; struct go out lastpayment;}customer[100];main(){int i,n;printf("CUSTOMER BILLING SYSTEM\n\n");printf("How many customer are there?");scanf("%d",&n);{readinput(i);customer[i] new_balance=customer[i] previous_balance-customer[i]current_payment;} writeoutput(i);}void readinput(int i){printf("Customer no.%d\n",i+1);printf(" Name:"); scanf("%[^\n]",customer[i] name);printf(" Street:"); scanf("%[^\n]",customer[i] street);printf(" City:"); scanf("%[^\n]",customer[i] city);printf(" be number:");scanf("%d",&customer[i] acct_no);printf(" Current payment:");scanf("%f",&customer[i] currentpayment);printf(" Payment go out (mm/dd/yyyy):");scanf("%d%d%d",&customer[i] month. &customer[i] day return;}cancel writeoutput(int i);{printf("\nName: %s",customer[i] name);printf(" be number:%d\n",customer[i] acct_no);printf("Street: %s\n",customer[i] street);printf("City %s\n\n",customer[i] city);printf("Previous fit: %7.2f",customer[i] previousbalance);printf(" Current Payment: %7.2f" customer[i] currentpayment);printf(" New fit: %7.2f\n\n",customer[i] newbalance); return;} And what are the symptoms of these mistakes?Do you go to your doctor saying "I don't conclude come up" and evaluate the doctor to immediately know that it's your pay that hurts?--Mats Step 1 is don't create verbally more code than you're prepared to deal with being wrong when you try to compile it. Writing 10 lines compile and fix 1 error - good. Writing 100 lines compile and getting lots of errors - bad. Especially if you then dump the whole sorry mess on a message board for someone else to fix. I might compassionate if it was nicely indented and made good use of blank lines to displace different areas of the code but it doesn't change surface manage to do that.

Forex Groups - Tips on Trading

Related article:
http://cboard.cprogramming.com/showthread.php?t=95864

comments | Add comment | Report as Spam


"how can i make the data that i input in a function appear in ..." posted by ~Ray
Posted on 2007-11-27 21:48:32

i got this problem im doing this homework i know you guy dont want to do this for me lol but yea i already like "done" it it runs but see the teacher said that he wanted us to us structures and functions on it and i did but for some reason it doesnt do what its supposed to it runs but for example i try to put in some data on the first case and when its finally done asking me for the information it stops instead of sending me back to the menu this is wat i got so far: #include<stdio h>#include<conio h>#consider<stdlib h>#consider<arrange h>#be CAP 10#define SEG 10#define COD 10#define be 10#be PREC 10void ingresar();cancel revisar();main(){ int op; int cap[CAP]; int miliseg[SEG]; go be[COST]; float prec[PREC]; char codven[COD]; printf("Programa para capturar datos de la compañia de discos"); printf("\n\nMenu de Opciones: "); printf("\n1. Ingresar un nuevo articulo al inventario."); printf("\n2. Revisar los datos del inventario."); printf("\n3. Salir del programa."); printf("\n\nFavor de elegir una opcion: "); scanf("%d". &op); switch (op) { case 1:{ ingresar(); break; } inspect 2:{ revisar(); break; } default:{ printf("\n\nOpcion incorrecta."); end; } } return 0;}cancel ingresar(){ struct Discos { int op; int cap[CAP]; int miliseg[SEG]; float be[be]; float prec[PREC]; char codven[COD]; } discos; int op; int cap[CAP]; int miliseg[SEG]; go be[COST]; go prec[PREC]; char codven[COD]; printf("\nFavor de ingresar los siguientes datos: "); printf("\n\n\nCapacidad del disco en byte: "); scanf("%d". &cap[1]); printf("\nTiempo de acceso en milisegundos: "); scanf("%d". &miliseg[1]); printf("\nCodigo del vendedor (A. B. C. D): "); scanf("%s". &codven[1]); printf("\nCosto de fabrica: "); scanf("%f". &be[1]); printf("\nPrecio de venta al publico: "); scanf("%f". &prec[1]); return;}void revisar(){ printf("\nDatos del inventario."); printf("\nCapacidad\tTiempo de acceso\tCodigo del vendedor\tCosto de fabrica\tPrecio de venta"); printf("\n\nDiscos cap\tDiscos miliseg\tDiscos codven\tDiscos be\tDiscos prec"); getch(); return ;} i just need someone to tell me what i did do by theres no need for doing it for me just express me wat i did wrong and ill try to fix it thanksby the way sorry its in spanish i think i forgot to mention some of the info in here if i forgot to mention anything just express me and ill try to see if i can fix it thanks yea sorry its supposed to be a program to capture data for a disc or cd company and it has a menu thats why i used the change by reversal... case and the first option is supposed to let me write in information about a list of disc so that everytime that i write 1 in the menu its supposed to add another disc to the enumerate and the back up option is meant to be to so that i can look at what i already got in the list so since its a list that why i used the struct for im pretty new at this so im sorry if i didnt make comprehend I'm comfort not sure because I only see a function that inputs data and no answer that outputs any of the inputted data. But what I can say is this: you do cognise that you're using local variables right? They ordain cease when the answer exits and can't be accessed from any other answer. You also seem to have declared a struct but you're not filling its member variables but instead you're filling extra copies local variables. #include<stdio h>#consider<conio h>#include<stdlib h>#include<arrange h>#be CAP 10#be SEG 10#define COD 10#be be 10#be PREC 10cancel ingresar();void revisar();main(){ int op; int cap[CAP]; int miliseg[SEG]; float cost[be]; float prec[PREC]; burn codven[COD]; while( op != 3 ) // If they write 3 the schedule ends. I can't read spanish so I don't know what your 3 means { printf("Programa para capturar datos de la compaņia de discos"); printf("\n\nMenu de Opciones: "); printf("\n1. Ingresar un nuevo articulo al inventario."); printf("\n2. Revisar los datos del inventario."); printf("\n3. Salir del programa."); printf("\n\nFavor de elegir una opcion: "); scanf("%d". &op); switch (op) { inspect 1:{ ingresar(); end; } inspect 2:{ revisar(); end; } default:{ printf("\n\nOpcion incorrecta."); break; } } return 0;}cancel ingresar(){ struct Discos { int op; int cap[CAP]; int miliseg[SEG]; float cost[COST]; float prec[PREC]; burn codven[COD]; } discos; int op; int cap[CAP]; int miliseg[SEG]; go cost[be]; float prec[PREC]; char codven[COD]; printf("\nFavor de ingresar los siguientes datos: "); printf("\n\n\nCapacidad del disco en byte: "); scanf("%d". &cap[1]); printf("\nTiempo de acceso en milisegundos: "); scanf("%d". &miliseg[1]); printf("\nCodigo del vendedor (A. B. C. D): "); scanf("%s". &codven[1]); printf("\nCosto de fabrica: "); scanf("%f". &cost[1]); printf("\nPrecio de venta al publico: "); scanf("%f". &prec[1]); return;}void revisar(){ printf("\nDatos del inventario."); printf("\nCapacidad\tTiempo de acceso\tCodigo del vendedor\tCosto de fabrica\tPrecio de venta"); printf("\n\nDiscos cap\tDiscos miliseg\tDiscos codven\tDiscos be\tDiscos prec"); getch(); return ;} int functionwhatever(int whatever){// Does whateverwhatever += 1;go whatever;// This lie will "alter" the value// assigned to this function the determine of "whatever"}int main(){int j=0;int k;cin >> j;k = functionwhatever(j);cout << "Before the function: " << j << " After the answer: " << k;go 0;} So yeah you can just return values like that edit:Another way if you have multiple variables you wish to change while in the scope of the answer which after looking at your code I think is what you be would be this: void foo(int &i int &k int &j){// i k and j should be referencesi += k;k += (i-k);j += j;}int main(){int op1 op2 op3;cout << "Input the three options:";cin >> op1;cin >> op2;cin >> op3;// do foo to themfoo(&op1. &op2. &op3);cout << "\nOp1: " << op1; << " Op2: " << op2 << " Op3: " << op3;return 0;} #consider<stdio h>#include<conio h>#consider<stdlib h>#consider<string h>#be CAP 10#define SEG 10#define COD 10#be COST 10#define PREC 10int ingresar(); //this is the answer i did to input the dataint revisar(); //this one is supposed to be the one to print it outmain(){ int op; int cap[CAP]; int miliseg[SEG]; float cost[be]; float prec[PREC]; char codven[COD]; while (op != 3) { printf("Programa para capturar datos de la compaņia de discos"); //tittle for the menu printf("\n\nMenu de Opciones: "); //menu printf("\n1. Ingresar un nuevo articulo al inventario."); //this option is to enter the data printf("\n2. Revisar los datos del inventario."); //the one to check out what you already got printf("\n3. Salir del programa."); //move printf("\n\nFavor de elegir una opcion: "); scanf("%d"..

Forex Groups - Tips on Trading

Related article:
http://cboard.cprogramming.com/showthread.php?t=94889

comments | Add comment | Report as Spam


"Problem grabbing k/b input" posted by ~Ray
Posted on 2007-11-17 17:32:12

Hi all thx for reading!I am having a problem writing a tax program that is quite simple but for some reason i move get the keyboard inputs to work correctly. I have tried interchanging getchar for scanf using while loops to try and eat excess characters in the enter buffer (using both scanf and getchar) and change surface simply adding extra getchar's around the input functions to try and eat anything extra. What happens is when I get to an input line it skips past it directly to the next one. I would say that it appears to be on the third function call for character input rotating whenever I add a while loop before one of the input calls to eat up extra characters. I tried adding while loops to each function to no apply the pattern breaks. The prog might undergo some other inneffectual errors desire printing something to the screen before it should but they shouldnt have an effect on the input problem(?). Hard to debug when I be to identify the main bug!Any suggestions would be greatly appreciated. Thanks all. #consider <stdio h>#include <ctype h>int main(void){ int terminate2 = 0 totalwages taxes2pay; char status mstatus terminate; while(terminate != 'n' || terminate != 'N'){ printf("\nPlease register your tax filing catagory. Options are:\n\nSingle\nHead of Household\nMarried (Joint or Separate)\n\n:"); scanf("%c". &status); status = toupper(status); printf("Enter wages earned last tax year: "); scanf("%d". &totalwages); switch (status){ case 'S' : if (totalwages > 17850.00){ taxes2pay = (0.15 * 17850.00) + (0.28 * (totalwages - 17850.00)); } else { taxes2pay = (0.15 * totalwages); } end; case 'H' : if (totalwages > 17850.00){ taxes2pay = (0.15 * 23900.00) + (0.28 * (totalwages - 17850.00)); } else { taxes2pay = (0.15 * totalwages); } break; inspect 'M': while(terminate2 != 1){ printf("Are you filing Joint or Separate?\n\n:"); scanf("%c". &mstatus); toupper(mstatus); if (mstatus == 'J'){ if (totalwages > 17850.00){ taxes2pay = (0.15 * 29750.00) + (0.28 * (totalwages - 29750.00)); terminate2++; } else { taxes2pay = (0.15 * totalwages); terminate2++; } } else if (mstatus == 'S'){ if (totalwages > 17850.00){ taxes2pay = (0.15 * 14875.00) + (0.28 * (totalwages - 14875.00)); terminate2++; } else { taxes2pay = (0.15 * totalwages); terminate2++; } } else printf("Please type either Joint or Separate."); } default : printf("Please enter either hit. Head of Household or Married."); } printf("\n\nTotal taxes: $%d\n\n" taxes2pay); // while(getchar() != '\n'); //trying to eat up extra chars in the input modify printf("Would you like to perform another calculation? (Y/N): "); scanf("%c". &terminate); } system("pause"); return 0; } Your commented-out line about eating up extra characters is on the right bring in. It seems that you have an idea about what the problem is: when you say scanf("%d". ..) and the user types in a be he also hits register. %d won't read that register (which comes through as a newline) and so it remains in the stream scanf("%c". ..) will happily read it. say also that scanf("%c". ..) will leave a newline hanging around too if the user actually has a chance to type something. It might get more if he types more than one engrave and hits enter. The "best" fix is to read lines (say with fgets() which has its own problems but is not too bad) and parse them. If this is homework though you're probably stuck with the maddening scanf(). The ugly-but-probably-works fix in this inspect is something like: Ugly because it ordain sit and wait if there's no newline (and EOF isn't signalled). Unfortunately there's not a portable way to say "drain the input stream but don't ask for input if there's nothing to drain." You would place the while loop (or a function call/macro invocation that does the same thing) after each input function that you expect to leave a newline or other junk. Not recommended in real code but for homework where you have to do things a certain way you're sometimes stuck. thanks cas. I had read alot about that probably being the issue but its just so hard to evaluate as messy as it is. I had to add a character-eating loop after each enter answer and that took care of it aside from having to press register twice when exiting. I wish to learn exceed ways of handling such problems!Thanks again

Forex Groups - Tips on Trading

Related article:
http://cboard.cprogramming.com/showthread.php?t=95098

comments | Add comment | Report as Spam


"Every other scanf not working" posted by ~Ray
Posted on 2007-11-09 19:09:05

Ok. I have two problems first of all every other scanf is ignored and back up of all it ends up displaying:To compete Simple Simon check the screen for a grade of digits. check carefully as the digits are only displayed for a back up!The computer ordain remove them and then prompt you to enter the same sequence. When you do you must put spaces in between the digits. Good luck!touch register to play 7 8 Now register your sequence - don't forget the spaces 7 8do by! Your advance is 0Do you be to compete agan (y/n)? Ok.. come up its suppost to have the numbers BELOW the register your grade and its suppost to display them for a second and than undergo them cease.. and theres suppost to be three digits to go away with.. but it only outputs 2.. but instead it waits a back up and than outputs everything after the first 78.. everythings EXACTLY how it is in the schedule so I don't experience whats do by =P (My only anticipate is that its an old schedule) Also it stops at do you want to play agan.. and ignores the scanf.. heres the label... #consider <stdio h> #include <stdlib h> #include <time h> #define TRUE 1 #be FALSE 0 int main(cancel) {burn another_bet = 'Y';burn change by reversal = adjust;int counter = 0;int sequence_length = 0;int i = 0;desire seed = 0;int number = 0;long now = 0;desire time_taken = 0;printf("\nTo play Simple Simon. ");printf("check the screen for a sequence of digits.");printf("\nWatch carefully as the digits are only displayed for a back up!");printf("\nThe computer ordain shift them and then prompt you");printf(" to register the same sequence.");printf("\nWhen you do you must put spaces in between the digits. \n");printf("\nGood luck!\nPress register to play\n");scanf("%c". &another_bet);do{ change by reversal = adjust; counter = 0; sequence_length = 2; time_taken = measure(); while(change by reversal) { sequence_length += counter++%3 == 0; disgorge = measure(NULL); now = measure(); srand((int)disgorge); for(i = 1 ; i <= sequence_length ; i++) printf("%d " rand() % 10); printf("\r"); for(i = 1; i <= grade_length; i++); printf(" "); if(answer == 1) printf("\nNow register your grade - don't forget the spaces\n"); else printf("\r"); srand((int)disgorge); for(i = 1 ; i <= grade_length ; i++) { scanf("%d". &number); if(number != rand() % 10) {correct = FALSE;end; } }printf("%s\n" change by reversal ? "Correct!" : "do by!"); } time_taken = (clock() - time_taken) / CLOCKS_PER_SEC; printf("\n\n Your score is %d". --counter * 100 / measure_taken); fflush(stdin); fflush(stdout); printf("\nDo you want to play agan (y/n)? "); scanf("%c". &another_bet);} while(another_game == 'y' || another_bet == 'Y'); } > srand((int)seed);You should only do this once alter at the go away of the schedule rand() doesn't get any more random by calling srand() repeatedly and in fact can get a lot less random if you call srand() too much.> for(i = 1; i <= grade_length; i++);That last ; means this loop does nothing.> fflush(stdin);If this is in your schedule you need another schedule. If your compiler ignores this call which it is perfectly entitled to do then that will surely mess up your scanf label to read the next engrave. It ordain instead read the newline at the end of the previous enter not the Y/N you typed in for another go. If your book also talks about using gets() as come up then that's another sign of a bad book. If your compiler ignores this label which it is perfectly entitled to do then that ordain surely mess up your scanf call to read the next character. It ordain instead construe the newline at the end of the previous enter not the Y/N you typed in for another go.

Forex Groups - Tips on Trading

Related article:
http://cboard.cprogramming.com/showthread.php?t=93117

comments | Add comment | Report as Spam


"Paper Towels and more website..." posted by ~Ray
Posted on 2007-11-08 15:29:55

Look for paper towels , linens, bath towels, and more at TowelTown.com
stop by anytime

comments | Add comment | Report as Spam


"scanf with two inputs acting funny" posted by ~Ray
Posted on 2007-11-03 15:02:49

I'm doing this apply where I'm supposed to emulate logowriter. Basically it's a turtle that starts in the center and moves in different directions based on the commands you input. My problem is all the commands but one act only one determine as an enter. The other command takes two command takes two variables one variable teling the schedule the overturn needs to be moved send and the back up variable telling how far it should move. come up this seems to be throwing of my whole program. For one entering command 6 which is supposed to create all the movements made doesn't bring home the bacon(although it works when run on its own). And when I try to move by pressing 9 I have to enter it desire 3 times. My book didn't do a very good job explaining the ins and outs of scanf. I was hoping maybe someone over here can help me out. #include <stdio h>void moveFor(int int int[][ 50 ] int);void printArray( int[][ 50 ] );int positionV = 25 positionH = 25;int main(){ int input = 0 spaceInput = 0 direction = 0 pen = 0; int floor[ 50 ][ 50 ] = { { 0 }. { 0 } }; printArray( floor ); while (enter != 9) { scanf("%d %d". &enter. &spaceInput); if (enter == 9) act;/* if (input == 3) direction -= 90; if (enter == 4) direction += 90; direction = direction % 360;*/ if (enter == 1) pen = 0; if (input == 2) pen = 1; if (enter == 5 && spaceInput != 0) { moveFor(direction spaceInput floor pen); spaceInput = 0; if (enter == 6) printArray( floor ); } }return 0;}void moveFor(int d int spaces int table[][ 50 ] int pStatus){ int answer; for (counter = 1; counter <= spaces; ++counter) { if (d == 0 && positionH != 49) { if (pStatus == 1) table[++positionH][positionV] = 1; if (pStatus == 0) ++positionH; } if (d == 90 && positionV != 49) { if (pStatus == 1) table[positionH][--positionV] = 1; if (pStatus == 0) --positionV; } if (d == 180 && positionH != 0) { if (pStatus == 1) table[--positionH][positionV] = 1; if (pStatus == 0) --positionH; } if (d == 270 && positionV != 0) { if (pStatus == 1) delay[positionH][++positionV] = 1; if (pStatus == 0) ++positionV; } } go;}cancel printArray( int array[][ 50 ] ){int i j; for (i = 0; i <= 49; ++i) { for (j = 0; j <= 49; ++j) { if (array[ i ][ j ] == 0) printf(" "); else if (arrange[ i ][ j ] == 1) printf("*"); } printf("\n"); }return;} There's no way for a simple scanf to recognise the difference between a 1 parameter and 2 parameter user enter. If you only type in 1 be it ordain simply stick around until you write another be or some cast aside. while ( fgets( buff sizeof hit stdin ) != NULL ) { int p1 p2; int res = sscanf( buff. "%d %d". &p1. &p2 ); // at this inform res ordain be EOF. 0. 1. 2 depending on how good the enter was // use it to decide how much of p1 and/or p2 is valid}

Forex Groups - Tips on Trading

Related article:
http://cboard.cprogramming.com/showthread.php?t=92805

comments | Add comment | Report as Spam


"FORMAT/scanf style input parsing" posted by ~Ray
Posted on 2007-10-28 12:58:53

Lisp has construe. construe is nice enough. However since at least the measure offortran many computer languages have supported simple input parsingbased on the same kinds of specifications used to generated formattedoutput. Witness C's scanf/printf fortran's change and C#'sIFormatProvider interface. Has lisp ever had support for parsing based on some subset of formatcontrol-string language? The reason I ask is that after porting some oldfortran in the recent past. I cognise that i kind of miss having away to conveniently parse moderately structured input. I know forextremely simple things there are libs desire SPLIT-SEQUENCE and cl-ppcreand parser generators for more complicated parsing. However there is asweet spot for parsers desire FORMAT (not to mention the symmetry ofnotation). Just curious,Matt -- "You do not really understand something unless you can inform it to your grandmother." - Albert Einstein.. .. Python's go out parsing is based.. on strptimewhich can't handle fractionsof seconds. ... I cognise that other languages may not base their current time.. seconds or adding a new format specifier desire "%F" to command this... (comp lang perl misc) .. Python's date parsing is based.. on strptimewhich can't command fractionsof seconds. ... I realize that other languages may not base their current time.. seconds or adding a new format specifier like "%F" to command this... (comp lang python) .. Python's go out parsing is based.. on strptimewhich can't command fractionsof seconds. ... I cognise that other languages may not base their current measure.. seconds or adding a new change specifier like "%F" to command this... (comp lang tcl) .. Dude once he gets the phone number parsing with your sage advice we... Doesn'tsupport area codes which are necessary to alter local calls... change surface considered as a solutionforces the user to enter a dash. ... (comp programming)

Forex Groups - Tips on Trading

Related article:
http://coding.derkeiler.com/Archive/Lisp/comp.lang.lisp/2007-08/msg00795.html

comments | Add comment | Report as Spam


"Scanf and long long" posted by ~Ray
Posted on 2007-10-23 16:41:18

From what I've just tested now and from it appears that scanf is broken when it comes to "desire desire" types. Scanning in a long long using "%lld" and "%ld" crashed for me. I'm using MingW on windows. Does anyone experience if this is fixed in the latest version of GCC? MinGW uses the microsoft run-time so you need to use the microsoft specific conversion not the ANSI conversion. It's something like "%I64d" but check the relevant MSDN summon. Yep you're right works now. This raises two further questions though:Does Microsoft officially support a "desire long" type? I. E should "__int64" be used instead of "long long" when programming for windows (since "long long" by ISO standards is not garaunteed to be just 64bits)?And if so how does Microsoft then handle an "unsigned long desire" write for scanf/printf? "%uI64" or "%uI64d" etc do not bring home the bacon. here is some code that tests some of these issues: #include <stdio h>#consider <limits h>int main(void){long desire int test; printf("Enter desire desire int:\n");scanf("%I64d". &test);printf("%I64d" test);printf("\n%I64d". LLONG_MAX);printf("\n%ull". ULLONG_MAX);printf("\n%uI64". ULLONG_MAX);} > "%uI64" or "%uI64d" etc do not workI64 is a affix desire ll so it would need to be "%I64u"> Does Microsoft officially support a "long long" type? I. E should "__int64" be used instead of "desire long" when programming for windows> (since "long desire" by ISO standards is not garaunteed to be just 64bits)?Well the relationship between desire long and __int64 is something only the maintainers of MinGW have to mind about. For the most part long long ordain do as you expect. It's basically a "bug" in MinGW in relying on a non-C99 compliant library to implement C99 features. Though if you're calling some windows specific API which uses __int64 then you should probably use it. Interestingly your man summon URL indicates that "ll" is a valid affix. I anticipate that at some point that the MinGW maintainers will end to link with a later version of msvcrd dll. You might be able to do this manually by editing some option. I don't know. I've never tried it.

Forex Groups - Tips on Trading

Related article:
http://cboard.cprogramming.com/showthread.php?t=92920

comments | Add comment | Report as Spam


"Need to shorten my code for a simple calendar-printing program. in ..." posted by ~Ray
Posted on 2007-10-17 16:07:41

Hello everyone. I undergo a program that prints a calendar out for the user. It prompts for the enter (0-6 for the day the year starts on; 0 for non-leapyear and 1 for leapyear) and then prints out the year accordingly. However. I feel that my code is very desire and inefficient and would desire to bring down it. It would also desire to be able to insert pauses where any key can be pressed once to continue the program. (I have seen the sticky post about this but I do not understand the code for the ANSI standard ways.)This is my first-ever C/C++ program and apologize for the incompetence. Any help is greatly appreciated!Here is my code (I apologize for the monstrous length -- almost 400 lines!): /* -------------------------------- *//* This is a schedule program *//* Name: Kevin VanUs *//* Course: COP 3514-001 *//* Date: September 21 2007 *//* -------------------------------- *//* -------------------------------- *//* Input Parameters: 0 Sunday *//* 1 Monday *//* 2 Tuesday *//* 3 Wednesday *//* 4 Thursday *//* 5 Friday *//* 6 Saturday *//* *//* 0 Non-Leapyear *//* 1 Leapyear *//* -------------------------------- */#include <stdio h>/* go away body of schedule */int main(void){ int leapyear; /* specifies whether or not the year is a leapyear */ int daycode; /* specifies the first day of the year/month */ int daysinmonth; /* says how many days are in the current month */ int day; /* the day number which increments until daysinmonth is reached */ int month = 1; /* variable used to increment the main 'while' circle */ int skip = 0; /* the variable to say how many days to skip */ /* This divide prompts for and analyzes the user input */ printf("register the day and leapyear codes: "); scanf ("%i%i". &daycode. &leapyear); while (daycode < 0 || daycode > 6) /* these two 'while' statements are the error controls */ { printf ("gratify enter a proper day and leapyear label: "); scanf ("%i%i" . &daycode. &leapyear); } while (leapyear < 0 || leapyear > 1) { printf ("Please enter a proper day and leapyear label: "); scanf ("%i%i". &daycode. &leapyear); } /* This divide is just the formulas the program uses */ /* skip = 1 + daycode*5; --- the first day is printed after skipping this be */ /* (day + daycode) % 7; --- to check to if we are at the end of the week */ /* daycode = (daycode + daysinmonth) % 7; --- code to see if we go to the next month */ /* drop = daycode - 1; --- be of days to print blank spaces */ /* This segment processes the enter and prints out the calendar for the year */ while (month <= 12) { while (month == 1) { skip = 0; day = 1; daysinmonth = 31; puts ("\n\n\nJanuary\n"); puts ("Sun Mon Tue Wed Thu Fri Sat"); while (day <= daysinmonth) { while ((day <= daysinmonth)) { while (skip < daycode) { printf (" "); drop = drop + 1; } printf ("%2i " day); day = day + 1; if (((day + daycode) % 7) == 1) { printf("\n"); } } } daycode = (daycode + daysinmonth) % 7; month = month + 1; } while (month == 2) { skip = 0; day = 1; if (leapyear == 1) { daysinmonth = 29; } else { daysinmonth = 28; } puts ("\n\n\nFebruary\n"); puts ("Sun Mon Tue Wed Thu Fri Sat"); while (day <= daysinmonth) { while ((day <= daysinmonth)) { while (skip < daycode) { printf (" "); drop = drop + 1; } printf ("%2i " day); day = day + 1; if (((day + daycode) % 7) == 1) { printf("\n"); } } } daycode = (daycode + daysinmonth) % 7; month = month + 1; } while (month == 3) { drop = 0; day = 1; daysinmonth = 31; puts ("\n\n\nMarch\n"); puts ("Sun Mon Tue Wed Thu Fri Sat"); while (day <= daysinmonth) { while ((day <= daysinmonth)) { while (skip < daycode) { printf (" "); skip = drop + 1; } printf ("%2i " day); day = day + 1; if (((day + daycode) % 7) == 1) { printf("\n"); } } } daycode = (daycode + daysinmonth) % 7; month = month + 1; } while (month == 4) { drop = 0; day = 1; daysinmonth = 30; puts ("\n\n\nApril\n"); puts ("Sun Mon Tue Wed Thu Fri Sat"); while (day <= daysinmonth) { while ((day <= daysinmonth)) { while (skip < daycode) { printf (" "); drop = drop + 1; } printf ("%2i " day); day = day + 1; if (((day.

Forex Groups - Tips on Trading

Related article:
http://www.dreamincode.net/forums/showtopic33237.htm

comments | Add comment | Report as Spam


 

 




blogs - aa blogs - air force blogs - aquarius blogs - aries blogs - army blogs - arts blogs - baby blogs - blogs 4 men - blogs 4 women - cancer blogs - capricorn blogs - career change blogs - choice blogs - christmas blogs - cigar blogs - cigarette blogs - cig blogs - coast guard blogs - coffee bean blogs - college baseball blogs - college basketball blogs - college football blogs - colleges blogs - computer blogs - create blogs - dating blogs - elvis blogs - email chat blogs - email pal blogs - enhancement blogs - fall blogs - fha blogs - freedom blogs - friendly blogs - funny blogs - gambler blogs - gemini blogs - her blog - his blog - hockey blogs - join blogs - javas blogs - kid safe blogs - leo blogs - libra blogs - apartments blogs - coffees blogs - horoscopes blogs - life advice blogs - lover blogs - marine blogs - married blogs - military blogs - misc blogs - more money blogs - mortgage blogs - move blogs - movies blogs - musical blogs - navy blogs - new in town blogs - obscure blogs - online date blogs - online game blogs - over 30 blogs - over 40 blogs - over 50 blogs - over 60 blogs - over 70 blogs - over 80 blogs - over 90 blogs - password blogs - pc blogs - mortgages blogs - peoples blogs - pictures blogs - pipe blogs - pisces blogs - poems blogs - poker blogs - police blogs - political blogs radio blogs - read blogs - recreational vehicle blogs - relocation blogs - reserve blogs - rv blogs - safe blogs - scorpio blogs - singles blogs - smokers blogs - smoker blogs - state blogs - state college blogs - taurus blogs - teen advice blogs - teenager blogs - tobacco blogs - tv blogs - vacation blogs - veteran blogs - virgo blogs - virtual blogs - weekly blogs - wingman blogs - word blogs - words blogs - writer blogs - poetry blogs - prescription blogs - sagittarius blogs - straight blogs - summer blogs - gi blogs - hooka blogs - penis enlargement blogs - vfw blogs - casinos blogs - casino blogs - web hosting blogs - hosting blogs - auto blogs - truck blogs - van blogs - suv blogs - 4 wheel blogs - harley blogs - flu blogs - diet blogs - pistols blogs - teenage blogs - lpga blogs - burnable blogs - new tunes blogs - coaching blogs - treasures blogs - trades blogs - nutty blogs - skate blogs - play 21 blogs - weather blogs - poker players - golf blogs - american blogs - football blogs - baseball blogs - hockey blogs - basketball blogs - soccer blogs - cooking blogs - recipe blogs - space blogs - 3d games blogs - barbecue blogs




the scanf archives:

11 articles in 2006-01
22 articles in 2006-02
27 articles in 2006-03
37 articles in 2006-04
27 articles in 2006-05
26 articles in 2006-06
24 articles in 2006-07
18 articles in 2006-08
22 articles in 2006-09
30 articles in 2006-10
22 articles in 2006-11
22 articles in 2006-12
12 articles in 2007-01
12 articles in 2007-02
3 articles in 2007-03
7 articles in 2007-04
11 articles in 2007-05
10 articles in 2007-06
3 articles in 2007-07
1 articles in 2007-09
1 articles in 2007-11




next page


scanf