Thread: resistor color code....

  1. #1
    Registered User
    Join Date
    Dec 2015
    Posts
    1

    resistor color code....

    Hello everyone, how are you feeling today?

    So first time, i have a problem and i cant seem to find the solution and i was wondering if any of you guys could lend me some of your time ? since you are reading this i assume you dont mind it

    I have this assignment, make a program in C that reads a number and then draws a resistor with the corresponding color code on it, for example a 22000 ohms resistor should equal a resistor with all strips red, my issue is that my program doest work and it returns me an "infamous" segmentation fault core dumped error..... i will be happy to provide more information if needed and iam sorry for any english mistakes i've made

    PS: iam coding with geany on a linux machine
    Attached Files Attached Files

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    I recommend that you post your code in [code][/code] bbcode tags instead of attaching a file. The reason is that if your code is so long that posting it as an attachment is a good idea, then it is probably also too long for people to bother reading it when they have neither their own interest nor payment as incentives. So, you should post a small amount of code, e.g., a standalone function that demonstrates the problem, or if that does not provide enough context, then the smallest and simplest (compilable) program that demonstrates the problem. You should also post the test input, expected output, and actual output (or in this case say that you faced a segmentation fault, which you did say).

    Anyway, one way to get started with debugging is to run your program using a debugger: set breakpoints in various places, then observe where the program crashes. You can then narrow down to the point where the program crashes: the mistake must then lie in code executed before that point. From there you can look out for things like accessing arrays out of bounds, making use of pointers that do not point to valid objects, etc.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Resistor value to color code and vice versa
    By Eddie Ramos in forum C++ Programming
    Replies: 15
    Last Post: 09-30-2012, 09:49 AM
  2. Replies: 7
    Last Post: 01-17-2012, 05:08 AM
  3. [code] coloring breaks [color]
    By quzah in forum General Discussions
    Replies: 46
    Last Post: 09-28-2011, 04:35 AM
  4. Help with a resistor decoder
    By usernameisvalid in forum C Programming
    Replies: 5
    Last Post: 06-25-2011, 05:21 PM
  5. Resistor Color Decoder for a 6 band resistor
    By nivoca in forum C Programming
    Replies: 2
    Last Post: 06-25-2011, 12:44 PM