q7.3 Fix the errors in the code (in C)
//This program uses a function called CharacterScan to read a char from the user
//The function must take an int pointer as a parameter
//The program should print the char and ascii code for each character the user enters
//The program should only exit whe nthe user enters escape
#include <stdio.h>
char CharacterScan(int*);
int main(void){
while(1){
int aCode;
int* iPtr;
char* c = CharacterScan(iPtr);
if(aCode)
break;
else
printf("%c is ASCII code %d.\n", c, iPtr);
}
}
char CharacterScan(int iPtr){
char c;
printf("Enter a character: ");
scanf(" %c", &c);
iPtr = &c;
return &c;
}
`Hey,
Note: Brother if you have any queries related the answer please do comment. I would be very happy to resolve all your queries.
//This program uses a function called CharacterScan to read a char from the user
//The function must take an int pointer as a parameter
//The program should print the char and ascii code for each character the user enters
//The program should only exit whe nthe user enters escape
#include <stdio.h>
char CharacterScan(int*);
int main(void){
while(1){
int iPtr;
char c = CharacterScan(&iPtr);
int aCode=iPtr;
if(!aCode)
break;
else
printf("%c is ASCII code %d.\n", c, iPtr);
}
}
char CharacterScan(int* iPtr){
char c;
printf("Enter a character: ");
scanf(" %c", &c);
*iPtr = (int)c;
return c;
}
Kindly revert for any queries
Thanks.
Get Answers For Free
Most questions answered within 1 hours.