ok i have made a calculator using turbo c but it keeps disappearing when i choose the run command can any body help me please
Well congratulations on bumping a five year old thread. In future, start a new thread.
ok i have made a calculator using turbo c but it keeps disappearing when i choose the run command can any body help me please
Well congratulations on bumping a five year old thread. In future, start a new thread.
use getch()
Just be wary that the getch() function and the associated conio.h header file are not portable.
you can use code blocks it's cool
I concur - Codeblocks is good.
But I use Eclipse far more often as it has support for other languages that I use (for work and for play). So for me, it's a "one-stop" shop as far as an IDE is concerned. And it's not too bad to configure for C development. I use the MinGW toolchain in combination with gdb. The debugger has some minor issues that should hopefully be sorted out soon - but generally speaking the set up works well enough.
Why are you even posting this piece of crap as a code snippet? Code snippets are usually posted by more knowledgeable members of this forum who have something useful to share with the rest of the community. That piece of rubbish should have been posted as a normal thread and more importantly a specific question should have been asked.
Before posting a code snippet, take a look at the real good snippets that have been posted and learn from it.
HI ,
I am a student in an university...
I am assigned a project about the knight's tour on the chess , but must use the Warnsdorff's rule ...
rule : Put a knight on the chess with any square , and find all patchs of knight (knight pass each square only once time )..
Who can help me???
Thanks lot...
SNIP
Well it's a minor miracle that you even got into university. You obviously didn't read this:
http://www.daniweb.com/forums/announcement118-2.html
I suppose you were hoping that some programming fairy was going to come along and sprinkle some magical fairy dust over your problem and woosh ... all answers would be revealed. You're just lazy mate.Show some effort; read the material on the above link and try again.
Oh for crying out loud. Stop being such a cry baby. You have posted enough messages now to know that you should be using code tags.
WaltP has kindly asked you on at least two occasions to use tags and you just choose to ignore the advice.
Since you're too bloody lazy to read the sticky threads on the opening page of this forum, here's a link on how to post code using tags.
Read it, apply it and you'll be surprised to find out how willing people on this forum will be to help you out if you show some friggin' effort. If you can't manage a simple exercise such as this, then you're in the wrong game.
http://www.daniweb.com/forums/announcement118-3.html
Ok here we go:
- you're missing the semi-colon after your declaration of the variable n.
- you haven't declared the variables i and count. And you don't need the count variable. Just print the value of i.
- remove the semi-colons from the end of your for statements - you have empty for statements here and that is why you are not getting the desired output.
- when counting back, initialize i to n-1.
- the code to print the required output should be part of an else clause - that way, if invalid data is entered, you don't end up printing erroneous values after printing your error message.
- in the future, use code tags when posting code - read the information at this link to learn how to do this:
http://www.daniweb.com/forums/thread93280.html
You're over-complicating this a bit. Have a look at the following snippet and see if you can follow what it does:
for (j = NUMBEROFBITS-1; j >= 0; --j) {
if (i & (1 << j))
putchar('1');
else
putchar('0');
}
NUMBEROFBITS is defined as the number of bits in an int for your system - for example let's say it's 32. The variable i is your input value.
i don't have code.simple plz
Here we go again - another lazy poster. If it's so simple then work it out for yourself.
You obviously haven't taken the time to read the rules and ethics on how to post to this forum.
aahahaha!
im not really in on reading rules
sorry!
im a newbie and just first year in my class so sorry to all disappointment!
^_^!im glad to join this forum!!
Mmm ... you're not really into reading rules. There are many members of this forum who won't be "really into helping you out" with that attitude. You'll get no "sweet sympathy" here with that modus operandi. Being a newbie and in first year is no excuse ... it just sounds like you're plain lazy.
Trust me; if you keep those types of responses going, you'll be subconsciously blacklisted before you know it (meaning - most members will choose to ignore you in the future). It's working for me already.
Going by your other posts, you may also take a little time to give your posts appropriate titles as well ... "here's the code" and "plz help" are crap titles for threads.
I suppose you still believe in the tooth fairy, Father Christmas and the Easter Bunny.
No one - and I mean no one is going to help you out based on the effort you have put in.
Read this:
http://www.daniweb.com/forums/announcement118-2.html
and this:
http://www.daniweb.com/forums/thread93280.html
and then this:
http://www.daniweb.com/forums/thread78060.html
I'll bet London to a brick, we won't here from you again (except perhaps for some whinge).
First up, as a newbie, you need to learn how to post code correctly on these forums using code tags. You'll find that people will be more willing to help you out if you're prepared to show some effort in this area. Please read the information at the following link to learn how to use code tags:
http://www.daniweb.com/forums/thread93280.html
Now moving on to your code. In addition to the anomaly that Samyx has pointed out, here are some other things to consider:
1. When using scanf() with strings, the address-of operator (&) is not required. You're doing this when scanning input for the student names.
2. While on the subject of the address-of operator, you're using them in the for loop that prints out student details - these are not required.
3. You have declared two variables (i and j) for use as loop variables. Only one is required (drop j).
4. You have a bug in the code that prints out first-class student details. You use the variable j in your loop statement and then use the variable i to reference your array elements. As in point 3, drop the j variable and change the code here accordingly.
5. A minor point - you can probably lose the else clause - the requirement only asks that you print the details for those students that are "first-class".
6. Try to avoid the use of "magic" numbers - you should probably declare constants …
THanks guys, lol but still stuck on the program, the one thing that has me lost , could you guys tell me if the loop area could be improved? Currently i tried to redo the program and declared my statement just like you guys told me to but i somehow feel the program crashes due to the loop not being complete
Try the following code snippet out and see if it matches your requirements. I'm assuming that you just wish to detect a single character input and when the correct key is entered, display a "successful" type message and exit the program. Otherwise keep on prompting the user with that "scary" message if he/she does not input the correct key.
#include <stdio.h>
int main() {
char KEY = 'a';
int Guess;
printf("You have traveled the World's Deserts and you have finally found the cave\n"
"of Ali Baba. You see the cave shut, and you shout the secret words:");
while ((Guess = getchar()) != KEY) {
// this line "flushes" the input buffer
while (getchar() != '\n');
printf( "You hear the sound of hooves closing in on you its the bandits, Please hurry and try again\n");
}
printf("You have opened the Cave and took all the riches of the Bandits, Well Done \n");
// pause program - enter any key + ENTER to terminate the program
getchar();
return 0;
}
A couple of things to note:
1) Using the getchar() function, you need to flush the input buffer to …
Are you kidding me? Why are you posting this as a code snippet? You should have posted this in the C forum as a "normal" thread". And quite frankly unless you are willing to put some effort in and pinpoint the minimal code that demonstrates your problem, I'd guess you're going to have a hard time finding people here prepared to help you when you dump the better part of 800 lines of code and virtually say "please look and fix for me".
can u hlp me about modulu and looping statement?
This old thread has been accidently revived. Stop posting on this thread (I know this is rather hypocritical of me).
Start a new thread and for crying out loud, formulate a proper question. Your rather vague question has no relation to the topic of the original thread in any case!!
Initialize k to zero.
Also, move your declarations for r and basechars outside of the loop.
@dkalita,
We do not freely give out code on these forums unless the poster shows some effort. Since you are a "newbie", you need to read this:
Besides all the other "evils" in your code that others have pointed out already, the logic of your max() function in your last post is incorrect. It appears to be returning the minimum value out of the three values passed in to the function.
You should consider yourself lucky that you're even getting people responding to your thread - you have made 10 posts and you still haven't figured out how to use code tags - although that is probably the least of your problems going by the poor quality of your code. You obviously need to study the core basics of C in more detail. And if you have, then you need to study harder.
It can't be that urgent if you can't even take the time to post an actual question. Try again - and ask a question this time.
Well I never expected such a reaction to my post #3.
@nateuni
First up, I apologise if that post offended you that much. In hindsight, I perhaps should have let the post sit in draft mode before pressing the ol' Submit button.
In my defense, I had been posting responses to quite a number of posts yesterday on this forum. A majority of these posts were of a similar theme i.e. poorly formatted code, vague questions and postings of "reams" of code (much of which lacked the necessary resources or functions to even get them to compile). But nevertheless I persisted and answered those posts which I thought deserved some sort of reply. Your post was one of the last I answered and the upper bound of my patience had been tested.
In the short time that I have participated on these forums, I have been PM'd quite a number of times by various members with help for problems - this was probably due to my "nice" nature. Initially I responded to their requests and then I realised that I was engaging in a disservice to this forum. I now politely ask the senders of such messages to re-post their queries on the public forum. The reason why I'm ranting on about this is to emphasis that I'm not a "nasty' person. I am passionate about the IT industry and I like to talk IT and mentor others when the opportunity arises. This is one of …
How many times do you need to be told to use code tags? It's the third time I have asked you to do this.
The strtok() function has its pitfalls which have been well documented - do your own research on this.
Since this is more than likely an assignment on using strtok(), I will only help if:
1) you post your code again using code tags (AND YOU HAVE BEEN GIVEN THE LINK TO THE NOTES ON HOW TO DO THIS IN YOUR PREVIOUS POSTS!!!)
2) you research how to use the strtok() function correctly and change your code accordingly.
Other than that, from my perspective, you're on your own.
>1. Passing into a function and then into a sub-function.
Did you asked Google? Anyways, I did it for you: http://www-ee.eng.hawaii.edu/~dyun/ee160/Book/chap6/section2.1.2.html>2. Passing 2d arrays, this had just mucked me up.
http://www.physicsforums.com/showthread.php?t=270319 and http://cboard.cprogramming.com/c-programming/97898-passing-2-dimensional-array-function.html>3. Making comparisons between pointers and ints
Sorry I did not got this properly to make any remarks. :)
I cannot believe students these days. With all the resources they have at their disposal and we have to put up with "Dear John" posts such as the one posted by the OP.
For crying out loud - YOU GUYS HAVE IT EASY
TO ALL YOU LAZY STUDENTS OUT THERE - use the resources available to you and then post a specific question. It amuses me how these students (so-called) post lines and lines of code and then attempt a subliminal approach to getting their questions answered.
Quite frankly, you can do us all a favour and get out of the CS/IT game altogether.
Just search for some Stanford University lectures on the internet (they're available via YouTube) on "Programming Methodology" and you'll understand my take on the lack of quality in the standard of CS education these days - it's an absolute joke! These courses have been "watered down" so much - and the flow on effect is the standard of questions that are asked on online forums.
PS: To all the "real" students out there (and you know who you are) - …
So what have you learnt (or even attempted) in the past two weeks?
http://www.daniweb.com/forums/thread208111.html
Obviously not that much.
Here's an idea, drop that Turbo C crap and move on to decent compiler/IDE setup.
I gave you a clue to this issue in your thread titled "GOTO command -C". You need to "consume" the '\n' character left over from when scanning the store number. Read my post again in that thread.
In your iMenu() function, replace:
scanf("%d", &iSelection);
with this:
scanf("%d%c", &iSelection, &cAgain);
I'm just reusing your cAgain variable - you should probably use a more appropriately named variable for this purpose.
Here are just some "tidy up" suggestions:
1. Your j (of type char) and ptr variables are never used.
2. Rather than declaring separate variables to store each character as you read the characters of the input string for each translation, just use one. The same goes for the variables used as array subscripts. You just need to reset the subscript to 0 before moving on to the next translation.
/*Changes user input to all upper case*/
pos = 0;
do {
c = input[pos];
c = toupper(c);
input[pos] = c;
pos++;
} while (c);
printf("Upper case: %s\n", input);
/*Capitalizes first letter of each word*/
pos = 0;
do {
c = input[pos];
c = tolower(c);
input[pos] = c;
pos++;
} while (c);
3. The gets() function is dangerous - use fgets() instead.
4. You can print your output for each translation using one printf statement:
printf("Upper case: %s\n", input);
Cheers,
JD
Damn! I did it again. I didn't realise the age of this thread. Sorry people.
It would be great if threads of a certain age could be locked so that numbskulls like me don't keep posting to them.
Rather than "eye balling" the two files and trying to detect the differences, use a file compare utility that is provided with your OS e.g. fc on Windows or diff on Linux/Unix.
Oh sorry, major errors occur at line 89....
I would advise you to develop this program and get one function working first before moving onto the next function. Trying to write it all in one hit and then resolving all the errors is a laborious chore and an inefficient way of doing things.
From having a quick look at your code (sorry it's Saturday night) and I ain't gonna be looking at all that code, I've put forward some issues to be addressed:
1. The signature of main() is incorrect - at the very least make it int main(void).
2. Most of your functions return int, but I don't see a value being returned to the caller via the return statement.
3. At the end of some of those function you appear to be trying to call main() - you need to return <int-value> in these functions to get back to main() or any other caller function.
4. I see you are using gets function. Lose it - it is a dangerous function - use fgets instead.
5. fflush(stdin) is just plain wrong - drop it.
6. You reference the getch() function which is non-standard - and at any rate you haven't included the conio.h header file.
Well, that'll do for now. As I said earlier try to develop the program one "feature" at a time and get THAT right before moving on to the next function. This program has far more …
<rant>
For crying out loud, is this a forum on how to shortcut the English language? Sometimes it feels like it's a tutorial on how to read friggin' SMS messages.
Then u noe hw 2 use do-while loop mar?
u=you, noe=know,hw=how, 2=to, mar=anyone's guess
Could u gv me the website tat can download c programing the notes n the example? Thx^^
u=you, gv=give, tat=that, n=and, thx=thanks
I am too very new in C... I ll try to solve ur prob.....
ur=your,prob=problem
Here's the deal; in the examples I quoted, there is a difference of 19 characters between the crapshoot spelling and the correct spelling (not counting whatever the hell "mar" means).
Get on board and at least try to use proper English.
</rant>
@9868, kimaeasha and abhi.navale
Why are you even attempting (and I use that term loosely) to help out yasaswyg? This poster, who is new to these forums (like me) has the audacity to call an extremely astute and knowledgeable poster (Salem) names and still expect assistance.
This is my take on the matter - unless the OP has the common courtesy to post again and issue an apology to Salem, then I say screw him (or her).
I mean take a look at the title of the post - "help, please, ASAP, I'm lazy, I don't have a clue, I can't be buggered even formulating a half decent topic heading for the post". And then they expect help.
Sheesh!
I'm still relatively new to these forums. I just like to put out a query regarding threads and their solvability.
For Daniweb forums, is it considered good practice for OPs to flag threads that they have started as being solved if they have received appropriate posts that have answered their question to their satisfaction?
I think this should be the case .. and perhaps a "sticky" of this nature should be posted at the head of the forum page.
Just my 2.5 cents.
@OP
I apologise if this remark seems a little out of place with respect to your query, but I would suggest that you look at using an up-to-date setup. Turbo C is pretty dated.
Personally, for the Windows platform, I would recommend the MinGW toolchain in conjunction with your favourite editor or IDE. Codeblocks is a good IDE option and you can download it with MinGW as part of the package.
I use MinGW in conjunction with the CDT tooling in Eclipse. It works well - except that there are still some integration issues with the gdb debugger - but it's not a "show-stopper".
Damn! I didn't realise this thread was started 4 friggin' years ago.
Thanks a lot ##k.k## - why did you "revive" a thread from 4 years ago that had been answered?
- and void main is still bad!
Sheesh
link to the assignment :
http://www.cs.bgu.ac.il/~clang092/wiki.files/assignments/assignment6.pdf
Here's a link for you:
http://donate_to_my_bank_account.com.au/
Seriously mate, help us to help you. Rather than posting all that code and saying there is a compilation error, how about try telling us what the error is and then perhaps posting a snippet of the code that is giving you grief.
Also, when posting code, please use code tags!
Sheesh!
You have a semi-colon at the end of your for statement in your code - that will prevent the prompting and gathering of more than one set of data.
You declare a variable called custDB - I think that should be cust.
You're applying the address-of operator (&) for the char array members of your data structure - that's a NO.
You're not providing an index for your cust array of type Customer when setting your data.
That being said, I have modified your code example to the point where you should be able to tweak it to suit the requirements of your assignment. It will prompt for two "sets of customer data" and print out a subset of that data. I have "chucked" everything into the main function - it will be your exercise to refactor that code into the functions required by your assignment. The rest is up to you.
#include <stdio.h>
#include <stdlib.h>
#define SIZE 2 // initially to test kept it to SIZE 2
typedef struct {
char firstName[30];
char lastName[30];
char street[35];
char city[20];
char state[3];
int zip;
char phone[15];
int accountId;
} Customer;
int main(void) {
Customer cust[SIZE]; // an array of Customer type of size SIZE
int i;
for (i = 0; i < SIZE; ++i) {
printf("\n");
printf("Enter Data for Customer %d\n", i);
printf("Enter First Last Phone: ");
scanf("%s %s %s", cust[i].firstName, cust[i].lastName, cust[i].phone);
printf("Address (Street City State ZIP): ");
scanf("%s %s %s %d", cust[i].street, cust[i].city, cust[i].state, …
what are the current trends in computer field?i have no idea
If you haven't noticed, this is a forum on the C programming language. You should post this message in a more appropriate forum and definitely provide more details as the term "computer field" is too broad.
@yellowSnow
And if fgets() returns NULL because of an error (and not because of end of file), then what?
My oversight ... my apologies.
Cheers.