User Profile

Collapse

Profile Sidebar

Collapse
MACKTEK
MACKTEK
Last Activity: Mar 27 '08, 01:07 AM
Joined: Mar 5 '08
Location: USA
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • In C, the compiler will not let me use #include in the same line as any other.
    So, not sure if this is "acceptable " per your rules.
    Code:
    #include<stdio.h>
    int main(){for(int i,j=1;i<2585;){printf("%d %d ",i,j);i+=j;j+=i;}}
    If not, then
    Code:
    int main(){for(int i,j=1;i<2585;);i+=j;j+=i;}}
    will work, although you wont get any output, the series is there in the variables....
    See more | Go to post

    Leave a comment:


  • MACKTEK
    replied to MSVC can't find strtok()?
    in C
    Not sure.
    I found a simple example here.

    [code=cpp]
    // StrTokens_Forum .cpp : main project file.
    /* strtok example */
    #include "stdafx.h" // added this.

    #include <stdio.h>
    #include <string.h>
    using namespace System; // added this
    int main ()
    {
    char str[] ="- This, a sample string.";
    char * pch;
    printf...
    See more | Go to post

    Leave a comment:


  • MACKTEK
    replied to code for atoi(ascii to integer)
    in C
    Vee10,
    I am surprised by your post. Don't you have any code you can show that give us some idea that you are tyring to figure this out?

    A little info to get you started.

    You already posted that you "know" what it does ie ascii to integer.
    Just remember that it takes the number represented and converts it to an integer.
    For example in MSDN
    s = " -9885 pigs"; /* Test of atoi...
    See more | Go to post

    Leave a comment:


  • MACKTEK
    replied to printing 0 to 1000 in console screen..
    in C
    Ah, now that is a neat idea... I had the same problem when I tried to do a logical expression with a WriteLine statement, so I just moved it to a different line. But, It would be neat to know how to "trick" the compiler into converting a function that has void as a return type into a function that returns a value....
    See more | Go to post

    Leave a comment:


  • MACKTEK
    replied to printing 0 to 1000 in console screen..
    in C
    At first I thought it might be impossible without an "if statement".
    But then I remembered &&., and applied recursion using that logic.

    I was able to complete the task.
    I would be interested in hearing from the experts tho, what tricks they would use. PM if you feel it would reveal too much.
    See more | Go to post

    Leave a comment:


  • MACKTEK
    replied to simulated annealing
    in C
    Your code is not organized.
    So, I have to admit, following the logic is not very easy for me.

    Try making some changes:
    Instead of having individual function names for each city... put each city in an enumeration like this:
    enum city { New_York, Dallas, Charlotte, Atlanta };

    This will give the value of 0 to New York, 1 to Dallas, 2 to Charlotte.... etc.
    Then create an array called CityName. CityName[0]='New...
    See more | Go to post

    Leave a comment:


  • MACKTEK
    replied to Nearest 2d coordinates
    in C
    Lets do this using the Socratic method.

    First, do you know whether or not you are supposed to use cartesian coordinates? or polar coordinates or some other type?
    See more | Go to post

    Leave a comment:


  • MACKTEK
    replied to static vairaible in class templates
    in C
    You can declare static variables either locally or globally.

    Local static variables are specific to the class or function or block of code.
    The nice thing is that no matter how many time you call that piece of code, the SAME variable value is there. The compiler knows not to initialize a static variable more than 1 time.
    So, yes every instance of a class that has a local static variable will have access to the SAME static...
    See more | Go to post

    Leave a comment:


  • MACKTEK
    replied to Reverse terminal output
    in C
    There seems to be a possible fix.
    Using something called non-canonical mode.
    I am not a linux programmer, so good luck.

    http://cboard.cprogramming.com/archi...p/t-27714.html...
    See more | Go to post

    Leave a comment:


  • MACKTEK
    replied to static vairaible in class templates
    in C
    can you be more specific, maybe add an example.
    See more | Go to post

    Leave a comment:


  • MACKTEK
    replied to namespace problem
    in C
    Do either of the sets of code share the same names of functions or variables?

    If not, then it seems all you have to do is declare both set of files under the same namespace and then include them.
    The #pragma once tells the compiler not to use include if they were already included elsewhere...

    For example:
    // namespace_Forum .cpp : main project file.
    #pragma once
    #include "stdafx.h"
    ...
    See more | Go to post

    Leave a comment:


  • MACKTEK
    replied to Reverse terminal output
    in C
    You can do what you want to do using _getch() and _putch()
    you will need #include <conio.h>

    The _getch() will grab a keypress without echo to the screen.

    So, you will have to write a program to handle what you want printed to the screen... using _putch()

    So, for example you can write a loop using _getch and print out using _putch but not print when they press a space or an "enter" key....
    See more | Go to post

    Leave a comment:


  • MACKTEK
    replied to program using TSR in C language
    in C
    Here are some links:

    www.thescripts. com/forum/thread779644.ht ml

    http://www.cplusplus.com/doc/tutoria...structure.html

    www.google.com for C++ tutorial....
    See more | Go to post

    Leave a comment:


  • In a simple test, I used
    {
    struct MyStruct {
    int i;
    char c1;
    char c2;
    char c3;
    char c4;
    char c5;
    int ii;
    };
    I commented out c2 thru c5 to see the development of memory use.
    The struct used 4 bytes for each int.
    For the First char it used 4 bytes, and did not use any more until the 5th char.

    So it seems it is allocating 4 bytes...
    See more | Go to post

    Leave a comment:


  • First I want to thankyou, I had not seen the floor() function before.

    Perhaps you are looking for how to format your output?

    Try changing your line as follows:
    printf("%.2f\n" ,(floor(1000.0* fl)) );

    The %.2f tells the printf you want 2 places to the right of the decimal.

    There's a whole bunch more on how to format your output here.
    See more | Go to post
    Last edited by MACKTEK; Mar 9 '08, 04:18 AM. Reason: spelling

    Leave a comment:


  • Your are welcome. Scrugsy actually explained it all, I just interpreted!
    See more | Go to post

    Leave a comment:


  • MACKTEK
    replied to Input numbers output words problem
    in C
    I am thinking of a different method to do this.

    User inputs a number (in text).
    Convert to an Integer i (perhaps you can skip that if user enters integer directly)

    Then take int i and divide it by the maximum "place" value and cast it.
    For example
    hund=int(i/100);
    // this casts a division that would usually not be a whole number value into an integer... it does not round up, simply casts...
    See more | Go to post

    Leave a comment:


  • Using the Project Menu, and choosing Add Class, I made a class called Dyn_XML_Class. This is contained in Dyn_XML_Class.h

    In Form1 all I had to do was:
    #pragma once // exists as top of Form1.h
    #include "Dyn_XML_Class. h" // add this line.

    I then instantiated the class inside an event handler, add some extra lines of code and it worked. (At least so far.)

    One thing I noticed is that the...
    See more | Go to post

    Leave a comment:


  • MACKTEK
    replied to Botball- Recognizing Color and Claw
    in C
    It might be useful to know what you have successfully achieved in the past in regards to programming for robotics.
    See more | Go to post

    Leave a comment:


  • Check out "long long" and maybe "unsigned long long"

    My guess is those are supported.
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...