Is there a difference between the use of these two? In my book, a sentence says '木屋里总共只有两个房间和一张床' - could you say 一共 here instead of 总共?
could you say 一共 here instead of 总共?
Yes you can, '总共两个房间和一张床' means "two rooms and one bed in total" room and bed are grouped as features in the house, therefore '一共两个房间和一张床' (altogether) is also correct"
However, it would be weird to say "一共一张床" because "一共" should apply to more than one item (which you add them up together)
总共 = in total
"我们这里总共有十个房间" = "we have ten rooms here in total"
"我们总共十个人" = "we have ten people in total"
一共 = altogether
"我们这里一共有十个房间" = "we have ten rooms here altogether "
"我们一共十个人" = "we have ten people altogether "
The only difference between 总共 and 一共 is 总共 can be used to describe a single item but 一共 cannot. We say "总共只有一人" , but not "一共只有一人"
Notice: you can say "一共一元" because a dollar is one hundred cents add up together.
"一共一元" means "合共一元" ($1 altogether)