Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- void leia_string(char s[]) {
- int i = 0;
- char c;
- do {
- c = getchar();
- if( c != '\n'){
- s[i] = c;
- }
- i++;
- if((int)c >= 48 && (int)c <= 57) {
- printf("numero\n");
- }
- else if((int)c >= 65 && (int)c <= 90) {
- printf("letra maiuscula\n");
- }
- else if((int)c >= 97 && (int)c <= 122) {
- printf("letra minuscula\n");
- }
- else if((int)c == 40) {
- printf("Parentese '('\n");
- }
- else if((int)c == 41) {
- printf("Parentese ')'\n");
- }
- else if(c == '+' || c == '-' || c == '*' || c == '/' ) {
- printf("operador\n");
- }
- } while (c != '\n' && c != '\0');
- s[i] = '\0';
- }
- int main(int argc, char const *argv[]) {
- char *s;
- s = malloc(sizeof(char));
- leia_string(s);
- return 0;
- }
Add Comment
Please, Sign In to add comment