Search:

Type: Posts; User: C-UL8R

Search: Search took 0.01 seconds.

  1. Is it possible to redefine symbols, e.g. '!' or '~'?

    Hi everyone,

    I was wondering if it's possible to redefine ! to mean 'call my factorial function on the preceding value' and, because ! usually means 'not', redefine ~ to mean 'not'. I won't need...
  2. Replies
    9
    Views
    8,585

    I don't really know much about memory but I...

    I don't really know much about memory but I declared the pointer "filename" inside the function with "String filename;". I also tried declaring it like this: "char filename[50];" but that didn't fix...
  3. Replies
    9
    Views
    8,585

    I edited in regards to "String". I am trying to...

    I edited in regards to "String". I am trying to read it and print a character from it to main.c, not write to it.
  4. Replies
    9
    Views
    8,585

    Need help opening a user provided file

    Hi everyone,

    This is my first real attempt at file i/o stuff in C. The user should be able to choose whether to import the provided file or their own file, and I was able to open the provided...
  5. Why is my string duplicated in this very simple program?

    Hi everyone, this is a small snippet of code from my school project:



    #include <stdio.h>

    int main(void) {
    char menu[5][35] = {"Please select one of the following:", "A. Define Random...
  6. Replies
    5
    Views
    5,041

    A little late, but you seem to be defining quite...

    A little late, but you seem to be defining quite a few unnecessary functions. The code in headerMessage() can be cut-and-pasted directly into the nearly empty main() function for sure. I really don't...
  7. Replies
    2
    Views
    4,149

    Fair use vs. abuse of the comma operator

    Hi everyone,

    I recently discovered the comma operator in C and it has certainly been useful in my projects. However, I worry that evaluating many instructions in one line can quickly uglify the...
  8. Replies
    1
    Views
    5,181

    Why does this line of code loop infinitely?

    Hi everyone,

    Why does this line of code produce an infinite loop upon receiving invalid input, and how do I fix it?


    for (int i = 0; !i; i = scanf("%lf", &myDouble)) puts("Please enter a...
  9. Thank you laserlight! Very informative. My...

    Thank you laserlight! Very informative. My professor does indeed use a type prefix in the names of all functions and variables (e.g. int intA; char charC). He mentioned that it was helpful in earlier...
  10. I apologize if answering your condescending,...

    I apologize if answering your condescending, rhetorical questions upset you. You posted a fairly useless code snippet that seemed only to be there as a 'Hey look at me I can do what you did in 21...
  11. Your code is much shorter, but doesn't handle...

    Your code is much shorter, but doesn't handle invalid input, does not define boundaries and only allows input once. The fn prefix on function names was at the suggestion of my professor. goAhead...
  12. Calculations not being displayed, everything else working fine?

    Hi everyone,

    I'm writing a program that should take in a number, e.g. 12345, and convert it to what my professor calls engineering notation, e.g. 12k. My code is probably longer than it needs to...
  13. Replies
    5
    Views
    2,256

    Hi, laserlight! Unfortunately, my programming...

    Hi, laserlight! Unfortunately, my programming background is very surface level, and until now I've never really cared about what is good practice and what is not. Now that I'm starting a CS degree,...
  14. Replies
    5
    Views
    2,256

    Actually, I spoke too soon. I just had to store...

    Actually, I spoke too soon. I just had to store the result of calling the function back into the appropriate counter variable. Thank you!
  15. Replies
    5
    Views
    2,256

    Hi Salem, Returning the counter (and changing...

    Hi Salem,

    Returning the counter (and changing void to int accordingly) did not fix the problem. I'm not sure what I'm supposed to do with the returned value anyway.
  16. Replies
    5
    Views
    2,256

    Update on previous post; new problem

    Hi all,

    I've come a little farther in my C studies since my last post, and I decided to try my hand at building a custom function. The code is compiling, but the counters no longer count past 1. I...
  17. No context? Nothing? You may get better advice if...

    No context? Nothing? You may get better advice if you add some details about what specifically you need help with and what you are attempting to create.
  18. Replies
    19
    Views
    17,853

    Perhaps I'm mistaken, but it looks to me like...

    Perhaps I'm mistaken, but it looks to me like goto is indeed an ASM instruction. I was always told to avoid goto in C because it was too "Assembly-ish".
  19. Replies
    19
    Views
    17,853

    How can I improve/shorten my C code?

    Hi everyone,

    I'm still new to C, coming from a Python background, and I was wondering if you could suggest any ways to improve/shorten my code. It's for a first-year university assignment, but...
Results 1 to 19 of 19