I got this code. (It's more of a test code since I will use this as a function for my address book program)
This code is supposed to ask the user to input characters at most 20 and they should only be composed of alphabets/spaces..
I have removed the error from the main code but there's still this lingering error in the return part.Code:#include <string.h> #include <stdio.h> #include <ctype.h> int main() { char addressbook[6][30][0]; int current_record = 0, length, i=0; int address_count = 0; current_record = address_count-1; //variable for the current entry do{ printf("Enter the first name:"); //asks the user to input the first name of the entry scanf("%s", addressbook[0][current_record]); length = strlen(addressbook[0][current_record]); //gets the length of the input (should be less than 20) for(i=0; i<=20; i++){ if(isalpha(addressbook[0][current_record][i])||addressbook[0][current_record][i]==' ') { //checks if the input characters in first name are alphabets/a space break; // } //exits once it sees that the characters are composed of alphabets/space else { printf("You can only use alphabets and space and a maximum of 20 characters. Input again."); //puts a message that prompts the user to enter alphabets/space alone } //end else } // end for } //end do while(length<20) return 0; }
syntax error before 'return'.
It won't compile. Help me see what's wrong with the code?



1Likes
LinkBack URL
About LinkBacks



) now it's working. although it loops even though I've typed only alphabets and spaces. Do you know how to stop it looping after getting the desired input?