Start xLow at 50
start count at 0
while xLow not 90
add 1 to count
increment xLow
Is this really that hard?
Start xLow at 50
start count at 0
while xLow not 90
add 1 to count
increment xLow
Is this really that hard?
Check the documentation for your compiler. That's the best place.
I apologize for the lack of practical knowledge, still a beginner.
I guess it would be simpler if you were born with this information already, but since we're not, no apology necessary. And it's extremely obvious. :icon_wink:
Now, your tweak was completely useless, as you could tell. Here's why:
1: I showed 1 loop, you have 2
2: I showed 3 IFs, you have 1
3: I have 3 reads from each file, you have 1
Did I waste my time giving you the algorithm? Did you in fact desk-check your code like I implied? My guess so far is yes and no. How'd I do? :icon_rolleyes:
If you need a better explanation, let me know.
Since he hasn't been here since Jan 4th, I wouldn't hold my breath waiting for him.
I wouldn't "read" the second IF either if I designed it that way.
Assuming your files will always be in sorted order as you posted them:
Read from file in1
Read from file in2
loop until EOF
cmp = compare in1-line with in2-line
if < read in1 again
else
if > read in2 again
else
if =
do = stuff
read in1 again
read in2 again
endloop
Don't make the IF do so much work. It makes the statement too hard to read, and you will always read both files making the comparisons very inaccurate (and wrong).
Aren't you beginning programmers taught how to desk-check your code using pencil and paper?
Well, if it doesn't open the file, how can it calculate the data?
Where did you save the file?
Where is the program looking for the file?
Make sure they are the same place.
Please find someone to help you translate your question into English. The translation program you are using creates unintelligible giberish.
Look up and learn the file/directory commands that your compiler or OS use. An example would be something like the functions findfirst() and findnext() available in some compilers.
Before they stopped development it seems it was a very good and free IDE. Just because it's no longer under development, memory of it has not been erased. It's the same 'problem' we see in universities that refuse to leave Turbo C++ 3 & 4 in the past.
And it still works.
1) Not going to even look at code that is that poorly formatted. Learn to format your code if you want help.
2) Why do you assume we have time to test your program? If you ran it with a good set of data and it didn't have a problem, it's probably good enough.
So do it. There are many compilers to choose from.
And I was meaning to tell you how you can do it. We aren't a give-away coding site, you know. You probably need to read the Member Rules as asked.
Another rule of thumb:
Add to you code cout << "ptr-> " << struct->member << "\ndot. " << struct.member << '\n';
Which one outputs correctly? That's the one to use. And figure out why. In no time you'll understand it.
So I made some changes and got everything operational but the logic is wacked out. It seems like when I get bust to work draw doeskin. Not just these logical evaluations but the whole series that states the outcome of the game. I have never had so much trouble with a program before. Do you guys have any ideas of how I should handle this?
Sure. Explain in detail what the problem is. Input, output, what it should do, where it goes wrong. Details. Most of us don't have time to read and understand your code top to bottom searching for an unknown "doesn't work" problem.
Of course. Read the string from the user. Use the string as the filename. No magic about it.
Let me change your question and the answer to this is how you wold do the filename thing, too:
Hi. I was wondering if there was a way to have the user input a number into an integer and then use that as a value in an equation.
i just have to ask, ...would you consider being taught about files and records in Pascal a good way of learning about files records (or i think they are called structs or typedefs in C) for use in C.
I dont think so......... but would love to know an opinion or two on it.
My lecturer solidly believes otherwise, this is a frustration to me!but am willing to throw my hands up and be corrected etc :)
Learn Pascal just to learn C? And you should learn Spanish if you want to speak Italian! If you have to learn Pascal file records, it's unnecessary. Just learn structs in C. If you know Pascal file records, You basically know structs in C. Why learn one (useless) syntax to understand another that's almost the same.
I hope you misunderstood him.
Create a data file called Person.dat (or Person.txt)
Each line of the file (record) should contain Firstname, Surname, Postcode, dob.
The user must be able to:
i) Add a record to the file (append)
ii) Display the contents of the file
my issue is knowing where to start ?
Create your struct.
Ask for input.
That's where I'd start.
i didnt ask for a program... i asked whether there is any specific method to copy a exe file or zip file.
No.
is it possible to copy a zip file and exe file from one directory to another using c program?
Yes.
We have. Now you have to do something.
To make the program better, put the 'work' in a loop. That way you only need one % and /. When the number is 0 the loop is finished.
Open the text file
Read the text file into your structure
Search the structure
Display what you need.
The key is read. The program can only use data it's read. Without reading, the program has no information.
Now you're making sense. This is only possible with certain compilers because asynchronous input is not part of the C++ Standard. What'cha usin'?
What if there are 2 or more spaces between some words?
Did you count the first word? It has no space in front of it.
Did you consider the way many people now incorrectly write? They never add a space after a sentence -- just run the 2 sentences together.
Things to think about.
Unless I completely misinterpret you, no, you are making sense. What doesn't make sense is creating a file for each person. If you have 1000 people in your contact list, you're going to have 1000 files. This will make your program slow and use a lot of system (disk) resources.
You'd be better off making one file with all the contacts in it -- one contact per line would be easiest.
'a' has a numeric value. Addition and Subtraction work on the value. Therefore, 'a' - 'a'
is 0. 'b' - 'a'
is 1. 'D' - 'A'
is 3. 'A' + 3
is 'D'.
CMD keeps giving me the same prompt: "myDir is not a command" or something along those lines.
Ahhh, info that actually tells us something about your problem. Either:
1) There are compile errors therefore myDir was never built.
2) You are not in the directory where myDir.exe exists when you type the command.
You can't use 'normal numbers' like ints or longs. You need to come up with a system that allows you to compute 1 number at a time. Using arrays for each number where each array element holds 1 digit of the numbers might work for you.
Okay, thanks! But I'm still having trouble running my program from command line. How can I make it so that I can simply type "myDir blah.ext" from the cmd for it to print the directory ON the cmd window itself?
Thanks.
I'm now sorry I bothered to post. :icon_confused:
I tried googling doing -/+ 'a' operations in C and what they mean. I believe it's dealing with the ASCII values of character symbols? Am I wrong in that belief?
'a' is an ASCII character symbol that has a value, so you are correct.
What is the advantage of doing operations that way vs. normal character arrays?
The question makes no sense. That way is an arithmetic technique. normal character arrays is a data storage technique. They are both useful.
I think my problem lies in the capital function(). Only the first line capitalizes. I have gotten it t work in using cout, but it doesn't update the saved file.
I am confused in using the ifstream & ofstream in the same file at the same time so maybe my logic in where I am placing the declarations is off. I just don't know! I just want it to work so that I can then add the error checking and format/tweak it.
Your technique for learning to program needs work. Your technique is to write the entire program and try to fix everything at once. A better technique is to write 1 single necessary piece, get it working, then add the next piece.
So, if you are having trouble understanding I/O, write only that piece.
1a) Read the file
1b) Display what was read and make sure it's correct.
Now move on.
2a) Add write the file
2b) Check the file and make sure it's correct.
Now move on.
3a) Add capitalize the date
3b) Display the new data and make sure it's correct
...
So I'd start again and take it a step at a time. Use what you have as a template.
Probably differently than you did in your program. But since you didn't post any code, we can't tell what you did wrong.
How can I make it from here so that it can list only the directory list that matches a specified file name pattern. So for example, how can I code it so that if I type myDir *.c it would list all files with an extension ".c" in that current directory?
How do you make it list all the files? Figure that out and change it.
This brings me to my second question: how can I make it so that my solution file "myDir.c" can be ran from the command prompt? Navigating to my solution file in CMD and entering "myDir bla" doesn't do anything when it should print the current directory with full pathnames on CMD.
You need to use the command line parameters. See this series -- it may help.
What are you doing with let_number = tolower(letter[i][j]) - 'a';
?
Now, based on your description "it isn't reading correctly", do you think that's enough of a description for us to understand the problem? Please always give details so we can understand the problem. And where is the seg fault happening? 250 line of code is too much of a guess for us. Pinpoint at least the area of the error.
You waited a whole 15 minutes? Come on, guy, some of us have lives and don't live on the board!
As to your question, change the deal function to return 1 and only 1 card. Then you can created a dealHands function that will deal as many cards as you need to all people you have playing. Then when you need to draw 2 cards, you call deal twice.
waltP
sorry to be a pain but what is the code to itterate through the file doing different things with each line? is it any different from doing the same thing to every line?
No, it's no different.
Sorry, but what you are actually asking us to do is teach you how to do a loop, open a file, read a file, and create and store data into your class. This is a help forum, not a teach me forum. Your instructor should have taught you all the things I mentioned. Your job is to put them together to accomplish the project. Our job is to help you when you get stuck, not teach you from scratch.
Create the class
Open the file
Read a line
Place it in the variable
continue.
Pretty basic stuff.
Since you won't explain in why the link I posted is in error, I must assume it's correct, therefore Narue and I are correct, any you haven't learned enough C yet to know why you are not correct.
You are in unknown territory. Since you "found out a bit", you are now the expert and know more than the rest of us. It seems that no one has tried this before, therefore cannot help any further.
Closest thing I can think of is debug the code and find out what values a working cont has, then try to make your new font mimic it. Or copy your new font over one that works and see what happens. Save the original, of course.
WaltP-I think so you need to study more ,understand the difference between preincrement and postincrement....
The link you gave is only for postincrement....
Better you must read it properly....
Really? Please explain exactly what and were my mistake was. Please go through that link I gave point by point and explain where I am wrong.
You see certain syntactical expressions have a higher level of precedence than others By this I mean certain codes are "more important and so are executed first...for example ++ has a higher level of precedence that just + and brackets,namely () have an even higher order of precedence than ++ so the code below is saying
int n1=2;
int n2=0;
n2= (++n1) + (++n1);(reading from right to left; the same in this instance vice versa), increment n1(n1 everywhere in the program is equal to 2+1 which is 3..but brackets has a higher level of precedence than the + so n1 is incremented again, thus becoming 3+1=4 everywhere in the program...You now have simply 4+4 which is eight..Makes sense?
No. First of all, as a professional programmer, even I was confused by your description in the upper half of your post.
And in the lower half, there is no guarantee you are correct because n2= (++n1) + (++n1);
invokes undefined behavior, as Narue tried to point out. See this.
So, you can't tell if the answer should be 6, 7, or 8.
By reading the words on the background of the box you typed your post in. And all over the place CODE Tags are explained.
Yes
Start by explaining the problem in detail. I answered the question as you posted it. Now you are asking different questions that barely relate.
Both are new... I'm sure an announcement is coming.
Check your braces carefully -- top to bottom.
You didn't add QUEUE.CPP to your command line.
I doubt it. It's going to take detective work on your part to find out. Ever watch "Cold Case Files"? That's what you're up against. Trying to figure out what works today with 20-30 year old compilers is going to take time and effort to get the answers you need.
@WaltP You're being very convoluted. I understand you're not obligated to help, but your replies are very obscuring. If you can point out the obvious, I'd just appreciate that more. Thanks for your previous replies.
Sorry. I was trying to get you to think through your problem, and try to debug what you started with. Since you didn't bother to try any of my suggestions, I'll back out.
Good luck.