C/C++ >> Help Needed Please
Posted by Sebi on 06:49:00 09-10-2001
how is that possible? cuz the program or the pc doesn't know the alphabet... so how should he know the values inbetween a and m?
Posted by fsvara on 14:21:00 09-10-2001
That's really easy, and yes, the computer DOES know the alphabet. Ever heard of ASCII? ascii 65 is the 'A', 66 is 'B' and so on.

Anyway, I've made that prog and commented it extensively (it's not complicated). I hope you'll understand it (and maybe learn from it :) )

Btw, why do you have such excercises all the time? Do you learn C at school?

The program I made is located at http://svara.dyndns.org/alpha.c

Compile, run as "alpha <start char> <end char>", ex:
"alpha A Z" displays "ABCDEFGHIJKLMNOPQRSTUVWXYZ". [addsig]
Posted by Sebi on 18:14:00 09-10-2001
i thought about ascii, but wasnt sure...
Posted by speedy11 on 18:34:00 09-10-2001
Compiled and run but all that comes up on screen is:-
Usage : alapha
Will try to put right, but complete novice ,if you would put it right for me would be great.
Thanks for the help i will learn from it.
I'm starting to do a course on C programming at the end of the month.

Thanks.

[ This Message was edited by: speedy11 on 2001-09-10 18:45 ]
Posted by fsvara on 20:19:00 09-10-2001
It's not broken, if it says that it means that you have specified not enough or too many arguments. To list the whole alphabet, run it as

"alpha A Z", for A-M "alpha A M", for B-G, "alpha B G", etc....
Posted by speedy11 on 21:03:00 09-10-2001
Thats th problem it don't ask me to input letters,just comes up with what i said.
I'm using c++ turbo 4 is that the problem??
Posted by jgrant on 01:59:00 09-11-2001
The program should not ask for input. Once you compile it, go to the directory where the executable is and type 'ALPHA A Z'. It executes the program ALPHA, and gives it the arguments A and Z, bah, I am tired, I hope I am helping...
Posted by DavidITCS on 18:01:00 09-11-2001
I can help you with your problem; it is actually quite easy once you know a few secrets about characters. I will write it and then post it in just a few minutes.

~DavidITCS
Posted by DavidITCS on 18:55:00 09-11-2001
Code is finished for Alpha Output!

It took awhile because I was optimizing the code to deal with invalid input, etc.

To get it, please send me an email at DavidITCS@hotmail.com

I chose not to post it because I just joined YPN and do not know how to post code!!

~DavidITCS
Posted by fsvara on 19:07:00 09-11-2001
huh? I made a prog, too, and that's what we were talking about.... it's at http://svara.dyndns.org/alpha.c

It gets the stuff from the commandline....
Posted by DavidITCS on 16:05:00 09-12-2001
Your commandline program is good, but isn't really compatible with several kinds of input. This isn't a criticism, just a suggestion for something to work on. For example, you program can only output CAPITOL letters from A-Z. Why not a-z, z-a, etc.? This can be done with just a few simple lines of code. If you'd like to see how, msg back and I'll email you my program (don't forget to include your email address!!)

~DavidITCS
Posted by fsvara on 21:05:00 09-12-2001
i know how just gotta change the thing that checks for invalid input. in fact, i was just too lazy to lookup the ascii number for the 'a' and 'z'... ;p
Posted by speedy11 on 23:41:00 09-14-2001
Would ove to see the results.

[ This Message was edited by: speedy11 on 2001-10-11 22:38 ]
Posted by fsvara on 08:26:00 09-15-2001
you asked for a prog that list chars from one char to another. i did that. upper case or lower case doesn't matter, right? well, anyway, i'll change it now.

the new version will still be at svara.dyndns.org/alpha.c
Posted by Peter on 18:54:00 09-15-2001
lol, that was a big deal
Posted by fsvara on 20:06:00 09-15-2001
that's because i haven't changed it yet.. it's only the link to the doc on my server...
Posted by fsvara on 20:52:00 09-15-2001
Ok, it's changed now, it can also read both ways.. like Z-A and A-Z.

It's pretty badly coded, tho, at least that's my impression.. using conditions all the time... But perhaps it's just because i'm a bit sleepy atm
Posted by speedy11 on 00:07:00 09-16-2001
Thanks realy mean that did'nt mean to ge you all airy ated really .thanks again
Posted by speedy11 on 01:26:00 09-16-2001


[ This Message was edited by: speedy11 on 2001-09-16 10:59 ]
Posted by fsvara on 08:49:00 09-16-2001
of course it works, the link, it's ony my own server... and there hasn't been any downtime.

i wasn't sleepy because it was so hard to change but because i was changing it at 12 in the evening.

Who are you anyway, "anonymous"?
Posted by fsvara on 09:27:00 09-16-2001
Btw, I don't really know what these rather silly commentaries were supposed to mean. I didn't change it earlier because i thought the first version i made was good enough... upper and lower case doesn't really matter...
and reading from z-a... i don't think that was also necessary.. but whatever. There's still a problem:
alpha A z displays non-alphanumeric characters, too. Fix that yourself this time
Posted by speedy11 on 10:37:00 09-16-2001
Thanks for all your help,Will do.
Not sure if its my end but can't seem to get file from your server.Will keep trying.

[ This Message was edited by: speedy11 on 2001-09-16 10:54 ]
Posted by Peter on 12:07:00 09-16-2001
I really admire the people who come around and leech on a topic as anonymous - you seem to stand for what you say.

I'm not saying it's bad to post without being registered, but if you get into a discussion, you can at least identify yourself somehow.
Posted by speedy11 on 12:14:00 09-16-2001
PETER.
Can you get the file from fsvara ,i can't seem to get it .
Can you try ,I will then know if its me.
Thanks
Posted by fsvara on 20:31:00 09-17-2001
i asked peter to check it in irc, he said it worked
Posted by speedy11 on 21:49:00 09-17-2001
Still can't get the file,seems strange had no problem before.
Any chance you could e-mail the program to me.
bilenki@hotmail.com
Posted by speedy11 on 21:50:00 09-17-2001
Still can't get the file,seems strange had no problem before.
Any chance you could e-mail the program to me.
bilenki@hotmail.com
Posted by speedy11 on 21:50:00 09-17-2001
Still can't get the file,seems strange had no problem before.
Any chance you could e-mail the program to me.
bilenki@hotmail.com
Posted by speedy11 on 21:50:00 09-17-2001
Still can't get the file,seems strange had no problem before.
Any chance you could e-mail the program to me.
bilenki@hotmail.com
Posted by speedy11 on 22:54:00 10-11-2001
I sent the program in for marking,,
This is the result i had back :-

This question requires you to write a program to accept two characters from the user.
Note: not just letters of the alphabet but all characters from the ASCII set
For example if the two characters are 'D' and '9' the output should be:-
"9 : ; <=> ? @ A B C D"

Get the two characters using one of the following methods:-
Ch 1 = getchar();
Ch 2 = getchar(); 0r scanf("%c%c",&ch1,ch2);
Note that the characters in the example above were swapped round before printing.This suggestes that you must test which of the two characters is the highest.This can be done using the IF construct.
You can now print out the characters using the following code:-

for(loop = lowest; loop <= highest; loop++)
printf("%c",loop);

loop, lowest, highest, ch1 and ch2 are all declared as characters.

Posted by fsvara on 13:11:00 10-12-2001
see my e-mail reply on that
Posted by speedy11 on 00:55:00 10-18-2001
This is what i came up with,,a lot more simple.

#include <stdio.h>

void main()
{
char ch1, ch2, higher, lower, loop;

printf("\nEnter Two Characters > ");

ch1 = getchar();
ch2 = getchar();

higher = (ch1 > ch2)? ch1 : ch2;
lower = (ch1 < ch2)? ch1 : ch2;

for( loop = lower; loop <= higher; loop++ )
{
printf("%c", loop);
}
printf("\"\n");
}


[ This Message was edited by: speedy11 on 2001-10-18 00:56 ]