ok...i'm new to this c language and i was wondering what am i supposed to do if the user enters a string that is longer than my array size. for our assignment, we're supposed to ask for the user's name and our array size is supposed to be 20 characters. if the user enter something more than 20, we're supposed to give an error message saying that only the first 20 characters will be stored. for my code, if the user enters more than 20 characters, the additional character would be assigned to another variable. what am i supposed to do.
i'm using fscanf to accept the string but i read that it's better to use gets.
teteret 0 Newbie Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
teteret 0 Newbie Poster
teteret 0 Newbie Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
teteret 0 Newbie Poster
Aia 1,977 Nearly a Posting Maven
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
teteret 0 Newbie Poster
Lerner 582 Nearly a Posting Maven
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.