Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CODE fscanf(file, %2d:%2d %2d:%2d , &data->channel[ii].shows[j].begins.hour, &data->channel[ii].shows[j].begins.minute, &data->channel[ii].shows[j].ends.hour, &data->channel[ii].shows[j].ends.minute); fscanf(file, %3s %[^ ], data->channel[ii].shows[j].day, data->channel[ii].shows[j].showName); I want to scan in: 20:30 20:55 mon The Business

CODE

fscanf(file, "%2d:%2d %2d:%2d ", &data->channel[ii].shows[j].begins.hour, &data->channel[ii].shows[j].begins.minute, &data->channel[ii].shows[j].ends.hour, &data->channel[ii].shows[j].ends.minute); fscanf(file, "%3s %[^ ]", data->channel[ii].shows[j].day, data->channel[ii].shows[j].showName);

I want to scan in:

20:30 20:55 mon The Business 17:35 17:50 fri The High Fructose Adventure of Annoying Orange 9:00 11:30 thu The morning show 9:05 10:05 tue Natural World 19:00 19:30 wed World News Today

However, the scan i get is:

20:30 20:55 monThe Business The Business 17:35 17:50 friThe High Fructose Adventure of Annoying Orange The High Fructose Adventure of Annoying Orange 9:0 11:30 thuThe morning show The morning show 9:5 10:5 tueNatural World Natural World 19:0 19:30 wedWorld News Today World News Today

NOTICE THE SPACE BETWEEN monThe Busi.....

the first "%s" from fscanf(file, "%s %s", da.... scans the whole sentence. I was to seperate so that weekday(mon, tue, wed) are stored in data->channel[ii].shows[j].day, and name in data->channel[ii].shows[j].showName. Obivously the problem is with the %s, if i make it like "%3[^ ]c %[^ ]" it scans the weekday properly but not the show name. Help???

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design And Relational Theory Normal Forms And All That Jazz

Authors: Chris Date

1st Edition

1449328016, 978-1449328016

More Books

Students also viewed these Databases questions