Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I know how to create a function with variable argument list, but how do you create one when the argument type is unknown, something like MyPrintf(...) ? From what I've read CLR/C++ only supports known argument types, such as int,
MyPrintf("...array<Int32>^ arr)

and the calling function

int main()
{
   MyPrintf("One", "two", 3,4);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Do you mean get and set, see this link. If you want read-only, don't incloude the set. If you want write-only don't include the get. Include both if you want read-write.

xHellghostx commented: That works thanks! +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Warning. This YouTube video contains adult language
.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Deal, I'll give it to my daughter who already has three.

Toyota Prius (I aleady have one)

<M/> commented: kool +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I don't get it, what do I get if I say "No deal"? Do I get that car if I say "Deal" ?

For the Lamorghini: No Deal. I don't want it, cost too much in taxes and insurance, and it probably can't pass a gas station,

80 inch television

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Sorry, BigPaw, but I disagree. I lived in England for three years during 1970s while on active duty in US armed forces. All the English people I met and worked with were very friendly. I didn't preceive any of them as being arrogant, except maybe the royal family, but that is expected (I never met them).

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

just delete line 21, not needed since those pointers were not allocated by calls to malloc()

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I also agree. When I was working on a team several years ago, I was senior member and young people was ask me how to do this or that. My response: RTFM! and use google to do research. If they still couldn't figure it out then I'd help them. It's surprising how much we can learn by reading manuals, learned a lot more than I had intended.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

it's been off-topic for a couple of days now, but that's the way it goes in Geek's Lounge :)

diafol commented: Haha know what you mean +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Jesus isn't the only one who can raise things from the dead :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Here is a good tutorial, it's written in vb.net but its almost identical to C# because they both use .NET framework classes and namespaces.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Dani has said several times before in this forum that there is nothing wrong with resurrecting old threads as long as the new posts are relevant to the topic.

Here is one of the threads. I seem to recall others.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

C++ has supported an implicit return from main() since C++98, and C has supported it since C99.

Yes, I was just testing you to see if you knew it too :) Guess I'm getting obsolete.

deceptikon commented: ;) +12
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You can use qsort() in C programs.

You can make an array resize itself by calling realloc() to change its size. The array has to be initially declared as a pointer, something like this: int* array = NULL; You also need to have two more integers, one integer to keep track of the current number of elements in the array, and another to keep track of the next useable element. For example initially allocate 10 elements in the array, when those are used up you have to call realloc() to increse the array size before adding another value to the array. Since reallocating array sizes is time consuming task you should realloc() the array by some constant value to reduce the number of reallocations. The value of that constant value will depend on how large you expect the array to grow.

const int BlockSize = 50; // realloc size 
void allocarray(int** array, int data, int *nItems, int* curSize)
{
    if( (*nItems+1) > *curSize)
    {
        *array = realloc(*array, *curSize+BlockSize); // increase size of array     
        *curSize += BlockSize;
    }
    *(*array+*nItems) = data;
    (*nItems)++;

}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 12: Do not declare variables in switch statements like that, but declare FILE* at the top of main() so that it is global to the entire function.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You don't need to worry about that. Just call the registry functions and they will take care of all that complexity.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Check the hwnd parameter of winproc to see if it is the label you want.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The most portable way to do it is to use the macro toupper() and tolower(). Your program only works if the language is English and uses standard ascii character set. See this page

#include <ctype.h>

int main()
{
   char c = 'A';
   if( isupper(c) )
       c = tolower(c);
   else
       c = toupper(c);
}
Asmaa_2 commented: Thanks for your help +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
  1. remove the spaces in scanf() format specifier string -- should be "%s", not " %s "

  2. lines 24 and 26: use array[i].name to populate the array.

tux4life commented: Always accurate and to the point. :-) +13
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

because you have a rotton attitude?

Why does Michael have a rotton attitude

<M/> commented: yup :) +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I never had sex with that woman!

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Check the permissions on the folder and files to see if you only have readonly permissions. I don't know how that could have been changed, but worth a try.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Also, I totally disagree with Ancient Dragon, code completion is really nice to have regardless of skill level, and you certainly don't need to suffer the extra typing to "learn" programming properly

I learned to program a long time before intellisense was invented. I find intellisense annoying and slows down my coding. If I didn't know what methods/properties were available I had to look them up in a book, which means I learned a lot more than what I had intended to learn.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

your link is not valid. But here is how to do it

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

lines 3 and 4 are wrong, it's '\0', not '/0'

you have to clear the stringstream before re-using it. Put this after line 12

ss.clear();
ss.seekp(0); // for outputs: seek put ptr to start
ss.seekg(0); // for inputs: seek get ptr to start
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

but free speech and all that

"free speech" is not an issue here, no one has the right to free speech on privately owned forums. The right to free speech is only a government issue, not private issue. If Dani said you will be banned for posting "IMO" then she ccan do that. The only reason foul language is banned is because Dani said so. I've been on other sites where it's perfectly acceptable language.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

It's all handled by the operating system. The os contains a task scheduler whose job is to give cpu time to the various processes that are running. Here is an article that will interest you.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The database admin sent an email to everyone about a new antivirus program, the email stated something to the effect that if you want viruses then get this program. My reply was "I don't want it if it contains a virus". I meant to send it only to the db admin, but instead clicked Send All and it went out to about 200 people! Needless-to-say I got a few emails about that blunder :) The db admin wasn't amused.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You can do this from the Form level instead of a control like below. In the Form's properties you have to set KeyPreview to True for this to work

Public Class Form1

    Private Sub Form1_KeyDown(sender As Object, e As KeyEventArgs) Handles MyBase.KeyDown
        If e.KeyCode = Keys.A Then
            Button1.PerformClick()
        ElseIf e.KeyCode = Keys.B Then
            Button2.PerformClick()
        End If
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        MsgBox("Hello from Button1")
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        MsgBox("Hello from Button2")

    End Sub
End Class
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Post the code you have written and ask question(s) about what you don't understand.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I did that once too, emberrising.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Just as I suspected. You can't use = to assign a string, you must copy it. Note you don't need dupstr() function. Since salary is an int you need to convert from char* to int.

int i = 0;
while( fgets(line,sizeof(line),sourcefile))
{
     strcpy(Array[i].name, strtok(line,";"));
     strcpy(Array[i].job, strtok(NULL,";"));
     Array[i].salary = atoi(strtok(NULL,";"));
     ++i;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
diafol commented: nice +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 11: <=9 should be just <9 because there is no 9th element in that array.

line 13: should be printf("please input numbers\n"); no need for "%s"

line 14: "%s" is fof strings, "%d" or "%i" is for integers.

line 16: should be <8 not <=8, you want to run the loop 1 less than the number of elements in the array. Since there are 9 eledments in the array the loop should run 8 times (0, 1, 2, 3, 4, 5, 6, and 7)

line 18: should be <9, not <=9, for the same reason as that given for line 11 above.

tux4life commented: Made my post redundant ;-) +13
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

put it in a module

Module ConnectionHelper
    Public Function foo()

        'Begin reading config file to receive database info
        Dim fileReader As System.IO.StreamReader
        fileReader = My.Computer.FileSystem.OpenTextFileReader("config.txt")
        Dim configvars(0 To 3) As String
        Dim count As Integer = 0
        Do Until count = 4
            configvars(count) = fileReader.ReadLine()
            count = count + 1
        Loop

    End Function
End Module
TnTinMN commented: that works +6
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I've Downloaded Visual Studio Ultimate Which is Great!

Did you get the free 90 day trial version, or did you get the illegal free version. I'm certain you didn't pay $10,000 USD to get it legally.

mitrmkar commented: Hehe, you might be onto something here ... +14
triumphost commented: You can get it on DreamSpark free if you go to school :) +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

This is what you want in the General.cpp file, you need to identify the namespace. Dp the same with lowerbound.

int counternamespace::upperbound = 12;

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 10 is incorrect. The = is an assignment, and the == is comparison (boolean). The mikddle part of that loop statement tells how many times the loop is to run, so if you say c == 0 then you are saying the loop continues until c becomes 0. Since the value of c is already 0 (at line 7) the loop will do nothing. You need to put something else there so that the loop will print something the desired number of times. If you want the loop to continue 10 times than do this

for(i = 0; i < 10; i++)

[edit]What ^^^ said :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You'll find yourself segwaying from one desire to another..

Very true. I am segwaing between Jack Daniels (Hickup!) and Irish Mist. :) Happy New Year!

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

.will u modify that for me?

No. All you have to do is put all that code in the header file and delete the two *.cpp files.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

gdeneral.h is declaring two variables and that header file is included in both analyzer.h and test.h. The same variables can't be declared more than once or you get that link error.

The work around is to use the extern keyword in general.h and then declare the same variables again but without extern in one of the *.cpp files

#ifndef GENERAL
#define GENERAL
namespace counternamespace{
    extern int upperbound;
    extern int lowerbound;
}
#endif
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you will feel better after the New Year.

Unless he has a huge hang-over :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The problem is that you put the implementation code in separate *.cpp files instead of as inline code in the header files. You can easily prove this by replacing the constructor in the cpp file with inline code in the header file then recompiling. That will remove the constructor error. The reason is because templates can't be compiled before the data type is known. How is the template supposed to know what kind of data is Head when CircularLinkedList.cpp is compiled? It doesn't. This is one reason why you see a lot of inline code in template header files.

You're going to have to get rid of both *.cpp files (CircularLinkedList.cpp and ListNode.cpp) and move all that code into the header file as inline methods.

template <class T>
class CircularLinkedList{
public: 
    CircularLinkedList() {Head=NULL;} /* constructor */
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

My advice is to take a vacation from programming for a little while. you sound burned out and that could be disasterous for your job if you do programming there. All work and no play makes a very boring person.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

is it possible?

yes

tux4life commented: Most to-the-point answer ever seen :D +13
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

All those unresolved externals means that you have not written the implementation code for those functions. Make sure spelling, capitalization, and parameters are correct in all the *.cpp files.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Not only are fibers invisible to the kernel but they are invisible to all other threads. Fibers can only call other fibers and fibers never exit. Here is a decent article about c++ fiber class.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I'm trying to write a simple program that detects when files are changed in a folder (for another question here). It has a standard Windows with a TextBox and a couple buttons. Upon program start it calls .NET function FileSystemWatcher then sets up four event handlers for it. What I want is for the event handlers to write something to the TextBox, but VB.NET complains that shared functions can't access instance objects. I know a work-around in c++ by setting a global pointer to the instance which can be accessed by shared functions but can't think of a work around in VB. Anyone know how to do this?

The error is on line 30 of the code posted below.

Private Sub TurnOn()
        watcher = New FileSystemWatcher()
        ' Create a new FileSystemWatcher and set its properties. 
        watcher.Path = txtFolder.Text
        ' Watch for changes in LastAccess and LastWrite times, and 
        ' the renaming of files or directories. 
        watcher.NotifyFilter = (NotifyFilters.LastAccess Or NotifyFilters.LastWrite Or NotifyFilters.FileName Or NotifyFilters.DirectoryName)
        ' watch all files.
        watcher.Filter = "*.*"

        ' Add event handlers. 
        AddHandler watcher.Changed, AddressOf OnChanged
        AddHandler watcher.Created, AddressOf OnChanged
        AddHandler watcher.Deleted, AddressOf OnChanged
        AddHandler watcher.Renamed, AddressOf OnRenamed

        ' Begin watching.
        watcher.EnableRaisingEvents = True

        ' Wait for the user to quit the program.
        'Console.WriteLine("Press 'q' to quit the sample.")
        'While Chr(Console.Read()) <> "q"c
        'End While
        'Return True
        btnOnOff.Text = "OFF"
    End Sub

    Private Shared Sub OnChanged(source As Object, e As FileSystemEventArgs)
        ' Specify what is done when a file is changed, created, or deleted.
        txtFolder.Text = …