Thread: C Work Help Request

  1. #1
    Registered User
    Join Date
    Feb 2017
    Posts
    2

    C Work Help Request

    Hey everyone, new user here!

    So, I started learning C about 2 months ago in college and I can't figure how to do a requested assingment.

    The program I built has the function to convert Integers to strings, however my professor asked me to show the final result of strings in a Array, instead of using 'strcat' to add to a single array and I can't figure out how to do that. Also, he wants me to read from a text file the number and print out the number in string.

    Can you guys give me any tips on how to solve this?

    P.S. : It prints the value in Portuguese since I'm from Portugal

    Thanks!
    Attached Files Attached Files

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    You mean an array of words something like

    char words[30][20];

    > case '1':if(cont>=2)strcat(imprimir,"e");strcat(imprimi r," um ");break;//verifica caso dgito seja um
    Where you end up doing something like
    strcpy(words[0],"e");
    strcpy(words[1]," um ");


    Also, you have an over-reliance of global variables, which is increasingly hard to manage given the size to which this program has grown.

    Also, your indentation needs work as well.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Feb 2017
    Posts
    2
    Yes, it was something like that I was looking for.

    I agree completely with you. I rely way too much, and that is part of the problem. I look at the code and don't know where to start with the modifications.

    Thank you very much for the help!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Sorry, one more request for help
    By ericdabear in forum C Programming
    Replies: 3
    Last Post: 03-15-2010, 12:56 PM

Tags for this Thread