WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Since mkdir() is not a standard C/C++ function, it's not surprising it doesn't work. The standard language is designed to be ignorant of the 'outside world' (directories, screen, keyboard) so anything that uses them outside the rudimentary I/O is compiler dependant. You'll have to look through your compiler documentation to see what functions it provides.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

My bad. Let me know if you can read it now.

OK, now indent your code so it can be read. After every { indent 3-4 spaces, before every } unindent. Can't tell which open brace goes with which close brace with unformatted code.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

What was wrong with your first technique? It looked fine to me.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Get the return value from the msgbox call. It returns the button value pressed.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

What have you tried? The code posted doesn't have any file read at all.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Okay for your first question I should change the for statement to i<6

Yes now that you have pointed it out I see that there is a correlation between the two sets.

My outer loop is:
0, 1,2,3,4,5
the difference between that and what I need to print is
2,3,4,5,6,7
so the inner loop actually would appread to be the outer loop number +1 right?
so I could add 1 to i for the inner loop such as j=i+2; ?

Thank you

In both cases -- BINGO! Two loops is all you need. One outer for the lines, one inner for the *s based on teh line you're on...

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

WaltP it never occured to me at the time to preview my post but your absolutely correct and thank you for the pointer on initialization of the variable.

Hmmmm.... no comment :)

My thinking was that I since I needed to print six lines of star's that I would have the outer loop run six times, ...

Good thought.

then I needed an inner loop to run six times but increment by 2 such that I would have another loop run 2 times, then 4, then 6, then 8, 10 and finally 12 times so that my cout <<STAR; statement would be printed by the same number each time through so that I would have the following output:

** print 2 times
**** print 4 times
****** print 6 times
******** print 8 times
********** print 10 times
************ print 12 times

You just complexed it out of reason.

Let's think about this... (yeah, I know that's what we're doing... ;))
You have one outer loop that goes from 0 to 6 for(i=0; i<7; i++) That's 7 lines... What's wrong here? That you can fix easily.

Now you want 6 lines of 2, 4, 6, 8... *s. Your loop goes 0, 1, 2, 3...
Is there a correlation between what you want and your loop?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

If I understand right I needed to enclose my code in [] right?

No. You enclose the code in tags. You could possiblly use the PREVIEW button to see if your post looks right... ;)

I re-wrote the for statements although I thought that it was okay to declare variables earlier in the program and just place a ";" in the place of the the variable declaration in the for statement? I was unable to get the k variable to compile without first declaring it.

Yes you should declare your variables earlier in the program. And yes you can just ";" if you know what you're doing. The first position is not a variable declaraction is a variable initialization, the first value the variable has thru the loop.

Also, formatting is of primary importance. Every time you use { indent 4 spaces. Just before you use every }, unindent.

Formatted properly, you code looks like:

#include <iostream>
#include <string>
using std::cin;
using std::string;
using std::cout;
using std::endl;
int main()
{
    int i;
    int j;
    int k;

    const char STAR ='*';
    k=2;                    // What does this statement do for you?
                            // What's the value the second time thru the I loop?
    for(i=0; i<7; i++)
    {
        for(j=0;j<k;j=j++)
        {
            cout << STAR;
        }
        {                   // Why are you starting a new block?
            for(k=0;k < 14; k= k+2)
            cout << endl;
        }
    }
    return 0;
} //end of main function
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Format your code properly with code tags and finish your for statements (3 parameters, not 2) and repost...

Then we have something readable to work with.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You've mostly got it.

Each C 'string' ends in a character value of 0. That's what your "out of bounds" is really checking, really it's "end of string.

Commented (and formatted properly)

int find_ substr( char *s1, char *s2)
{
    register int t;
    char *p, *p2;
    for( t= 0; s1[t]; t++)  // Move character by character thru the source string
                            // start at the first character t=0 and s1[t] 
                            // until the current character s1[t] is 0 (FALSE)
    {
        p = &s1[t];         // p becomes the address of the current character
        p2 = s2;            // p2 becomes the search string

// Following tests to see if the current position in the source string and the seach string
// matches...
        while (*p2  &&      // Continue while *p2 is not 0 (TRUE) -- end of string not found
               *p2 == *p)   //            and source and search characters are identical
        {
            p++;            // skip to the next character
            p2++;           //    in both strings
        }
        if (!*p2) return t; // out of loop -- if the current character in the seach string
                            //    is 0, we have a match.  Return the substript of the start
                            //    of the sub-string
    }
    return -1;  // substring not found 
}
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Stupid question. I've noticed that most of the posts seem to sink to the very bottom of the page. Is it possible to reply to a specific post without this happening?

This is a stack, so no. All you have to do to respond to a specific post and still be understood is use "Reply with Quote" button.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

stan yost there is a simple way

lets say you want to pass the text feild of text1

1- declare a public variable in the general part of the form like this

public varaiableName as String

2- in the form_load() write

variableName=text1.text

3- you can access this variable from any other form using the form name

lets say you have form2 and you want to pass text1.text which is in form1 to form2 which has a text feild (text2)

you can do that like this:-

text2.text=form1.variableName

- Regarding calling methods You have first to decalre it as public intead of private sub ---> public sub

and u can do the same thing using the form name to call the function

form1.functionName()


I hope this helps

vbmenu_register("postmenu_246662", true);

lover99509, is this easier than using form1.text1.text as already recommended?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Hi VinC,

system("pause");

Use instead.

No, don't. Learn your tools. Using scanf() to read characters is even worse than using gets() because not only does it allow you to blow your buffer boundaries but as you can see it also leaves your input stream dirty. The \n is left in the stream for your getchar() to read.

Use a combination of fgets() and sscanf() for safety and to process the input stream cleanly.

fgets(tmpstr, 80, stdin);
    sscanf(tmpstr,"%d %[abcdefg] %s", &i, str, str2);

[edit]Since you already learned this from GID, you could check out the scanf() series there. [/edit]

Grunt commented: Rightly Said - [Grunt] +1
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Specify formName.fieldName.data

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I think some major clarificarion is needed.

I was wondering if anyone can help me in terms of using atoi to get my my results to add the 1's of my binary output and then join them together... eg. 110101 and 100101 is 4 and 3 = 43.

Do you mean you want to convert series of 1's and 0's typed in by the user into it's octal (base 8) representation? That's what this example shows. There is nothing decimal (base 10) about it. In decimal, this value is 37, not 43.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

And...?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I haven't read any of your posts to see what the problem is but it seems to me that if you are

1) Posting your code properly formatted
2) Using code tags
3) Explaining what is going wrong in understandable detail
4) Explaining what the code should do in understandable detail
5) Not making us guess what you are talking about
6) Not expecting to be taught by us (I believe we are here to help, not teach)

you should be having no problems.

[edit]
I just looked at the last two questions you posted and I see a lot of help you've been given. Useful help.

Then you said

NOPE NOT BROKEN I DONT CARE IF I USE CORRECT GRAMER ONLINE AS LONG AS IT GETS THERE AND THE PEOPLE CAN READ IT AND AS FOR ...

which is basically saying you refuse to communicate better and don't really care if half of us can't read your posts. I'm just going to assume you were frustrated and didn't mean to say that. Is that a correct assumption to make?

WolfPack commented: Good Advice +3
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I wasn't responding to DMR, I was responding to Salem.

DMR snuck that in while I was typing...lol.

Oh... :cheesy: That's why I usually quote who I'm responding to. It's really hard to follow generic comments when people sneak in....

But you did use gets() which is still a no-no.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I didn't resurrect it...I just answered t. Don't shoot the messenger.

What makes you think DMR was talking specifically to you? "Hello People" was the post salutation. The others could be people, too. :)

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

My preferred solution:

#include<iostream>
using namespace std;
int ReadInputFlava ();
int ReadInputCart ();

int main()
{
    int flava,cart,delivery;

    flava = 0;
    cart = 0;

    cout<<"            Mulaudzi Ice-Cream Limited\n"
        <<"            --------------------------\n";

    flava = ReadInputFlava();
     cart  = ReadInputCart();

    cout<<"Ur flava is : "<<flava<<endl;
    cout<<"Ur # of cartoons is : "<<cart<<endl;

    return 0;

}

int ReadInputFlava ()
{
    int a;
    cout<<"Please enter flavour(1=choco,2=caramel,3=mint) : ";
    cin>>a;

    return a;
}


int ReadInputCart ()
{
    int b;
    cout<<"Please enter number of cartoons(1-20) : ";
    cin>>b;

    return b;
}

This makes the program a little more modular. And I prefer not to pass values via the parameter list unless it can't be avoided. Personal choice.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

It's a cleaner code method to not include an else unless it's being used.

True, but for the question asked the else was unnessesary to expand because this is an example of how to use isNumeric, not an example of how to design an IF. And all I did was answer the question
asked, I didn't correct his value/text mistake because he would find it quickly enough, and the focus was on the question asked.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
If NOT [B]isNumberic[/B](Textbox1.value) then
    Msgbox("Sorry you must only put numbers")
else
end if
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Is there a simple way to create multi-line tool/tip text boxes ... nothing special, no balloons or anything, just multiple lines ???

Doesn't look like it. I tried an obvious way -- at least to me -- and it didn't work. In form load change the tooltip using

Text1.ToolTipText = "this is another test" + vbCrLf + "the second line"

Didn't work... The tooltip 'parser' doesn't process vbcrlf as a CR-LF. They are undefined characters so they came out as boxes.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

This is a bit basic but might help.

A bit basic! LOL That's a good one!!!! :D

See, BASIC is the language, so it struck me funny.... Oh, never mind!!

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Hi WolfPack,

ok..I've got what do u mean..and I already try it n it works..but..I still need to type the filename right?..If possible, I just want to run program.exe only but then it can read all the files inside the same directory.

This may not be necessary. If you use the filename *.fil, in the version of Unix I used the command line was expanded to include all .fil files. Then you only have to loop through the command line parameters if Red Hat works the same. Give it a try with something simple:

int main(int ac, char *av[])
{
    int parm=1;
    while (parn < ac)
    {
        puts(av[parm++]);
    }
    return 0;
}

See what happens. Add the headers, of course.


By the way, using scanf() to read strings is just like using gets() -- you should really us something safer like fgets().

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
Salem commented: Nice link to the CLC FAQ - Salem +1
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

And how does the program read the value n2?

The best way to answer these type of questions is to just try them:

int main(int argc, char *argv[])
{
    int param;

    printf("argc = %d \n", argc);
    for (param=0; param < argc; param++)
    {
        printf("%2d)  %s \n", param, argv[param]);
    }
    return 0;
}

Write a small program to test only the problem in question to understand how the specific technique works. Then once you understand it, go back to the program you're working on and incorporate what you've learned. This way you may in fact write 5 small programs instead of just one big one but you'll understand the specifics better and faster. You will have your information in minutes instead of hours or days...

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

use getline()

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

So I try "\-126" and get a compile error. Any other ideas?

-126 is 82 hex -- try \x82