This is a part of a series on how Africa’s youth boom is changing the continent, and beyond.

Portia Stafford, a petite and usually soft-spoken 22-year-old, shouted through the razor wire at the burly men guarding the construction site in Soweto, a sprawling township in South Africa. Pumped up with frustration and anger, she and a dozen young friends threatened to storm the site where a new settlement was being built.

They wanted — no, they demanded — jobs.

When a guard threatened to shoot, the group backed off and Ms. Stafford felt her resolve deflate. Shaken but unharmed, she made it home that day in February to the concrete-block bungalow that she shares with her parents and three young relatives.

Ms. Stafford, her sister and two cousins all have high school diplomas — historically a ticket to a decent job in South Africa. But all of them were still unemployed after searching for work for years. Their quest has been full of humiliations and surprises. Ms. Stafford’s odyssey has taken her to a company that vanished when she was supposed to pick up her check, a pyramid scheme and even, unwittingly, a brothel.

“There’s no moving forward,” Ms. Stafford said. She frets that only those with connections succeed, but she said, “I keep trying to get a job, and I go all out.”

She is part of a generation of South Africans, born nearly a decade after the fall of the apartheid regime, who expected to have better prospects than their parents and grandparents.

She lives in the Soweto neighborhood of Kliptown, where, in 1955, anti-apartheid activists, including the African National Congress that now leads the country, adopted the Freedom Charter — principles that still guide the nation. Among them was “the right and duty of all to work.”

South Africa is the most industrialized country in Africa and was once considered an economic success story. But it has one of the highest youth unemployment rates in the world — 61 percent of people ages 15 to 24 are unemployed, according to Statistics South Africa, a government agency. The overall unemployment rate is 33 percent, and 35 percent for high school graduates.

If South Africa, the most developed economy on the continent, cannot create enough jobs, economists warn, then how are poorer countries in Africa going to generate opportunities for their booming youth populations?

Much of the industrialized world is facing the opposite problem. In the coming decades, parts of Europe and Asia are expected to have the oldest populations in recorded history, with extraordinary numbers of retirees depending on shrinking numbers of working-age people to support them.

Africa, by contrast, has plenty of young people with higher expectations than ever. A push to get more children in the classroom has paid off: Forty-four percent of Africans graduated from high school in 2020 — an increase from 27 percent two decades earlier. But the shortfall of jobs could push them deeper into poverty and desperation.

About one million Africans enter the work force every month, researchers found, but fewer than one in four find a formal job. So, young Africans, even those with college degrees, do menial labor, accept payment in food, migrate to other countries on the continent looking for better opportunities and cross oceans in rickety boats to find work.

Even relatively stable countries are failing their young labor force: Ghana’s tech industry has not created abundant jobs, while in Botswana, one of the continent’s fastest-growing economies, college graduates languish.

Ms. Stafford and her friends spend their days in Johannesburg, South Africa’s economic engine, going from store to store to drop off their résumés. She fills in applications on her cellphone with rapid taps of her thumbs.

In January, she dropped off her résumé at a police station. In February, she sprinted to the local post office to put her name on a sign-up sheet for a temp job. In March, she signed up to volunteer at a social service nonprofit. One Saturday in April, she woke early to join a cleaning crew that was part of a public works program, a model inspired by a Depression-era program in the United States. None of those led to a job.

Ms. Stafford had been the beneficiary of a national experiment to make the high school curriculum more practical. She learned how to keep books in business studies, to cater to guests in tourism, and to run a professional kitchen in consumer studies. She hoped these subjects would give her an edge in the job scramble. School wasn’t easy for her, but she kept at it, even after getting pregnant. Her son is now 4 years old.

Looming over her neighborhood of shacks is a four-star hotel, built when South Africa hosted the FIFA World Cup in 2010, intended to bring tourists and jobs to Soweto. Despite her tourism training, Ms. Stafford has never dropped off her résumé there because she knows no one in her community who has ever been hired there. (The hotel manager did not respond to an interview request.)

Ms. Stafford’s parents had dropped out of high school to find work during South Africa’s tumultuous transition from apartheid. For a while, Johnson and Anna Niewenhoudt, teenage sweethearts who met on their neighborhood’s bald soccer field — he on the team, she in the crowd — had it relatively good. They had four children together, two girls and two boys.

Mr. Niewenhoudt earned enough in a steel factory to add two extra rooms to their modest house. The girls had their own room, and the boys had one, too — a luxury in their neighborhood of open sewers and dirt roads. The family had an electric stove and a flat-screen TV. All the children went to school.

Then the steel factory mechanized, replacing Mr. Niewenhoudt with a robot. Now he runs a welding business from his backyard, making wrought-iron gates. When power blackouts silence his grinder, Mr. Niewenhoudt rummages through a landfill to find anything to recycle for cash.

“If he’s home,” said Ms. Stafford, watching her father sweep his workshop, “it’s very bad.”

If he earns nothing, the family has tea for dinner. As a sign of faith, the girls boil water on a gas cooker, preparing for whatever Mr. Niewenhoudt brings home: pap, South Africa’s staple of ground maize; potatoes; maybe even bones for a broth.

Ms. Stafford’s job search became even more desperate when she began noticing spots on her father’s eyes — which the family believes is scarring from the welder’s flame. The second eldest, she had to pick up the slack when her eldest sister, Nochrisha, gave up looking for work after a fruitless decade.

Nochrisha Stafford is one of the 3.2 million South Africans classified as “discouraged work-seekers.” (If they were to be included in the official unemployment rate, it would rise to 42 percent from 33 percent.) The family has watched helplessly as she succumbed to depression and alcoholism.

One Thursday around noon, Nochrisha Stafford wandered unsteadily into the kitchen. She opened the empty bread bin, then slapped it shut.

“We need soap,” she said, slumping into a chair.

Then she told her mother that the loan shark that the family borrows money from to get by each month wanted her $2 back.

“Tell her I’ll give her month end,” Anna Niewenhoudt said.

The family pools their welfare payouts — about $28 a month for each of the four children in the house, plus $19 for each unemployed adult. But it’s only enough to buy food for two weeks.

While seeking work, Portia Stafford tried to run a business from the kitchen. She baked two dozen muffins several times a week, the smell of mint chocolate chip filling the house by 7 a.m. Her younger brother sold them on the playground, and she gave him a cut of the nearly $4 she made with each batch.

In doing so, she joined the more than 80 percent of workers in sub-Saharan Africa who scrounge out a living in what is called the “informal sector.”

Teenagers in Lagos hawk cellphone chargers in rush-hour traffic. Women in Nairobi grill maize at bus stops. Optimistic policymakers envision turning these entrepreneurs into formal business owners. But Ms. Stafford’s muffin enterprise shows how challenging that really is.

Inflation drove up the cost of her ingredients so quickly that she lost money.

One Tuesday morning in May, she and two friends pooled the little money they had to take a taxi to what was billed as a job fair. It was nothing but a pyramid scheme. However, they spotted a hotel nearby, and decided to drop their résumés there. A beefy man appeared and directed them to a side door, saying that all the girls looking for work entered there.

It turned out to be a brothel. They fled as fast as they could.

In job seekers’ groups on social media, Ms. Stafford had seen dozens of stories of women lured to interviews, only to be attacked. In South Africa, Black women have the highest unemployment rate, and they are also most vulnerable to crime and poverty. Ms. Stafford and her friends always moved around as a group.

They thought they had found real jobs when they heard of openings with a company that said it had a government contract to help seniors register for ID cards. The company’s address was a house, and the interview was in a kitchen. Their prospective employers fired off a few interview questions while eating fries drenched in vinegar. The smell reminded the friends how long it had been since they’d eaten.

They were hired on the spot. They set off, going door to door, sticking together as they faced barking dogs and muggers.

When they went to pick up their paychecks, their new employers had disappeared. The people living in the house said they had never heard of the company.

But the construction site protest finally seemed to pay off. The owners agreed to hire two people from Ms. Stafford’s block. But since nearly every house had someone who was unemployed, a fight erupted over who would get the two slots. A community leader suggested a lottery, with each job seeker assigned a number.

The winning number was 37, and it happened to belong to Ms. Stafford’s cousin, Boitshoko Mokgobi, who shared a room with her.

Instead of excited, Ms. Mokgobi was guilt-ridden. Ms. Stafford told her cousin, “At least one of us got something.”

But when Ms. Mokgobi showed up to the construction site, the bosses just laughed at her skinny frame. They told her to go home and send a man from her family instead.

So she did. Her 21-year old male cousin, Thabo Wessels, replaced her.

At last, someone in the family had a job. The family cooed over him in his overalls and packed his lunch.

When payday arrived, he disappeared. They found him a day later, carousing with Ms. Stafford’s eldest sister, his check spent on a bender.

Ms. Stafford’s luck finally began to turn in June, when she was admitted to a six-week computer training course, where she progressed from typing with one finger to four. At her graduation ceremony, her mother shouted and whistled.

Back home, Ms. Stafford carefully placed her new certificate in the cupboard, on top of the same certificate that her still-unemployed sister had received a few years before.

The computer course yielded no job for Ms. Stafford, either, but it created an opportunity.

A family friend tipped her off that the same nonprofit agency was training young women to run a day care program in the building. “Connections,” she said, laughing sheepishly.

By October, Ms. Stafford and a friend with whom she had dodged dogs and brothels took charge of more than a dozen toddlers. She expects to earn 500 rand, or $26, a month — below minimum wage, but coupled with the welfare she receives for her son, it will nearly double her income.

Ms. Stafford is already planning to open her own child care center. It isn’t what she dreamed of or trained for, but it’s her first reliable paycheck since graduating from high school nearly two years ago. As she cleaned up the bowls of watery sorghum porridge she had fed the toddlers, she was feeling overwhelmed but, after long last, hopeful.