As mentioned, Captain of Co. "K", 32nd North Carolina Regiment. James Foster was killed in action at Winchester VA on Sept. 19, 1864. The only James Foster I can find to fit your description (name = James Foster, date and place of birth = 1824 NC) lived in Ohio in 1860.
It might be worth checking a later census for him, such as the 1880. Wish he had lived for possible inclusion on the 1890 veterans census. Sometimes Confederate veterans were listed by accident.