ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have a assignment relating to barcode reading.Let say i have to enter the 13 digit barcode with hyphen e.g "Enter barcode:123-46574-48847" using scanf.Once thats done how do i extract the values without the hyphen
e.g using printf "1234657448847". No arrays No strings and No function is allowed.
No while loop is allowed
The lecturer's tip was to treat "-" as negative and not hyphen.
Per the LQ Rules, Do not expect LQ members to do your homework - you will learn much more by doing it yourself.. We're happy to assist if you have specific questions or have hit a stumbling point, however. Let us know what you've already tried and what references you have used (including class notes, books, and Google searches) and we'll do our best to help. Also, keep in mind that your instructor might also be an LQ member.
I have asked that this thread be moved to a more appropriate forum.
As to this question i actually did 3/4 of my work. i just need the last piece to solve my problem.Let me explain what i did so far sudo code
int main(int argc, char*argv[])
{
long long bar;
printf("Enter the barcode:");
scanf("%lld", &bar);
printf("Barcode is %03lld-%06lld-%03lld-%01lld\n",
bar(first3digit),(BAR2(the next5digit),Bar3(The next3 digit),Bar4(the last digit));
This program scans the 12digit number and once that done what i did was to separate the 12 digit number accordingly to the barcode e.g 123456789012 to 123-45678-901-2
its all good from here. The problem i'm facing is that now someone input numbers and hyphens into my program
e.g 123-45678-901-2 how do i convert it back to 123456879012 with without char str,no strings,no arrays,nofunction. Just by using scanf to convert it back
As to this question i actually did 3/4 of my work. i just need the last piece to solve my problem.Let me explain what i did so far sudo code
int main(int argc, char*argv[])
{
long long bar;
printf("Enter the barcode:");
scanf("%lld", &bar);
printf("Barcode is %03lld-%06lld-%03lld-%01lld\n",
bar(first3digit),(BAR2(the next5digit),Bar3(The next3 digit),Bar4(the last digit));
This program scans the 12digit number and once that done what i did was to separate the 12 digit number accordingly to the barcode e.g 123456789012 to 123-45678-901-2
its all good from here. The problem i'm facing is that now someone input numbers and hyphens into my program
e.g 123-45678-901-2 how do i convert it back to 123456879012 with without char str,no strings,no arrays,nofunction. Just by using scanf to convert it back
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.