No, this will not cause a memory leak in the way you suggest. fscanf
does not reassign word
, but rather modifies its contents. You may wish to think of it in terms of: fscanf
doesn't change word
, but does change word[0]
, word[1]
, etc.
After a call to fscanf
, word
will still point to the same location in memory (i.e. whatever you got from malloc
), but the data at that location will be different.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…