English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

#include
#include
#include

void main () {
char n;
int x;

printf("\n\nEnter your name:\t");
scanf("%c",&n);


if(islower(n)){
n=toupper(n);
printf("the converted character:\t%c",n);

}else{
n=tolower(n);
printf("the converted character:\t%c",n);
}


if(isalnum(n))
printf("\nthe character is neither a letter nor a number.\n");

if(ispunct(n))
printf("that is a punctuation");


//input name
printf("\n\nEnter your name:\t");
scanf("%s",&n);

//char as string
for (x=0;x<100;x++){
if(n[x]!='\0'){
if(islower(n)){
n=toupper(n);
printf("%s",n);
} else {
n=tolower(n);
printf("%s",n);
}

system("pause");
}

2006-11-19 00:04:47 · 4 answers · asked by cL@iRe 2 in Computers & Internet Programming & Design

4 answers

Well, you ask the user to input a name. Then you read one character. Then you ask for the name once again, and you read again a single character into n.

Then again in the for loop you use n as an character array and it was declared as a single char. So you are accessing memory that doesn't belong to you.

To do what you want n should be declared as char n[101];
then initialized with zeroes via a memset(n, 0, 101);

And then you could either use scanf to read the name all in one statement, or if you insist on reading character one by one, scanf would have to be inside the for loop.

2006-11-19 02:41:26 · answer #1 · answered by Yoda Miyagi 4 · 1 0

first, what problem are you seeing? the char n is just 1 character, you need an array to get multiple characters. you are missing a couple of brackets } near the end, so you would get a compile error.

2006-11-19 01:17:43 · answer #2 · answered by justme 7 · 0 0

That looks like a DOS read out of some sort. Try this go to http://www.download.com/Advanced-WindowsCare-Personal/3000-2086-10407614.html?part=dl-AdvancedW&subj=uo&tag=button and download this program. It's a fantastic program to get your registry and windows in order. Good luck, plus it's free. Mikie.

2006-11-19 00:33:29 · answer #3 · answered by Mikie 3 · 0 2

مرحبا

2006-11-19 00:14:46 · answer #4 · answered by ramzy r 1 · 0 1

fedest.com, questions and answers