请问如何读取文件每行第一个单词?
我需要统计一个文件中开头单词出现字数。我用 fscanf ( fp, %s, 2048)读取每一行,但是我不知道怎么才能读取每行中第一个单词。# This is a comment
Figure A 100 100 =
# figure A (2 diagonal line segments)
draw 100 100
draw -100 100
End Figure A
# ############################
Figure B 10 10 =
# figure B (a square)
draw 390 0
draw 0 390
draw -390 0
draw 0 -390
End Figure B
# ############################
printFigure A
printFigure B
drawFigure A
drawFigure B
translate A 20 30
drawFigure A
child pause 2
child clearScreen
# child end below is last line in input file
child end
Figure A 100 100 =
# figure A (2 diagonal line segments)
draw 100 100
draw -100 100
End Figure A
# ############################
Figure B 10 10 =
# figure B (a square)
draw 390 0
draw 0 390
draw -390 0
draw 0 -390
End Figure B
# ############################
printFigure A
printFigure B
drawFigure A
drawFigure B
translate A 20 30
drawFigure A
child pause 2
child clearScreen
# child end below is last line in input file
child end
需要读取的文件是这个样子的。。。非常感谢!! 第一次学编程。。