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
    1,135

    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
    1,135

    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
    1,135

    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
    913

    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
    556

    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. 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
    469

    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
    469

    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
    469

    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
    469

    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
    1,234

    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
    1,234

    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