Sharpshooters were often used as expert skirmishers. In some cases, "sharpshooters" were used as part of the line of battle. It was, after all, seen as just another onerous task that almost any infantryman could perform.
In the Union, there were both formal and informal ad-hoc sharpshooter units. Included in the former were regiments, battalions and companies that met the War Department's qualification for sharpshooting. This would include Berdan's Sharp Shooters, First Michigan Sharp Shooters, First New York Battalion Sharp Shooters, First Maine Battalion Sharp Shooters, etc. The latter were units raised in the field and manned by reputable (for the most part) marksmen who were detached from their parent organization and temporarily assigned to the ad-hoc command. There are numerous examples of this in both the Union Armies and the Confederate Army of Northern Virginia.
The Confederacy didn't have marksmanship qualifications. They had five methods of selecting men for sharpshooters. Not all of them yielded the most qualified candidate for the job either. Go here for an article on it:
http://www.bivouacbooks.com/bbv9i1s1.htm
Not everyone who was an expert marksman joined a sharp shooter unit. The core of any regiment or battalion either North or South was a community based company. Folks enlisted with their brothers, fathers, uncles, co-workers, school mates, nephews, neighbors, friends, etc. They were loathe to part company to join a special unit of sharp shooters that was composed of strangers. Thus it could be found in most units a soldier who was a proficient marksman. That soldier would be called upon at times for a special task. "Take out that officer."
A few exceptional soldiers had access to "telescope target rifles," the period's vernacular for scoped rifles. Soldiers equipped with these often got to select their own spot on the battlefield. Sometimes they would be given special tasks like removing an enemy sharp shooter who was harassing their side.
Mind you, possession of such a weapon does not automatically make one a sharp shooter. In my own research, I have found one instant where a soldier wanted one to stay out of the charges. In another, one soldier bought one so he could play sharp shooter and avoid his normal duties as an infantryman.
Noted author of sniping history and former Curator of the Royal Armoury Museum at Leeds (UK), Martin Pegler wrote an article on the Corn-fed Sharp Shooters. We have corresponded with each other in the past.
http://milpas.cc/rifles/ZFiles/Articles/History/Confederate%20Sharpshooters/Confederate%20Sharpshooters.html