thanx Salem. I think you just solved my problem. although I had to add '*' before Mydict in the strcpy function.
Type: Posts; User: littlerunaway
thanx Salem. I think you just solved my problem. although I had to add '*' before Mydict in the strcpy function.
I don't quite understand why I need malloc. don't I already assign the memory in the struct definition when I define the dict0 points to 5 characters long array?
I have a variable (Mydict) which is struct type, which includes a pointer (dict0) to an array of chars (5 of them). now I want to assign a word to that array and can't figure out how to do it.
I...
I'm writing this program for yet another home work and I'm stuck on a very small part of it. I wrote a short separate program that includes my problem. I added the program and what I get when I run...
working on it. it doesn't come to me as easy as you may think.
yeah, 12a34 is a complete failure, I need to print an error, trow the whole thing away and check the next number.
so if scanf fails because of a character, I can get rid of that character with getchar()? did I understand correctly?
so if I have 12a34, scanf fails with the 'a', getchar() takes it away, the next...
"scanf(%d) stops at the first character which isn't a number and leaves that character (in your example 'a') in the input stream.
Thus if you try to use scanf(%d) another time (at your next...
that's why I got an infinite loop. I see. I can't really use those methods to get rid of the unwanted data cuz they don't really let us use things we haven't learnt in class yet.
I actually wrote...
hey
I'm new to c and programming in general and there's something I can't figure out. I was hoping you could help me.
I'm writing a program (home work) that supposed to receive a list of 5 digit...