Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

vtputs (Char * f)

{

char cbuf[1024];

 

strcpy(cbuf,f);

strcat(cbuf,"\n");

vtProcessedTextOut(cbuf, strlen(cbuf));

 

return(0);

}

 

 

Please , How would be the above code written in VB.Net.

Posted

I'll tell you what that c code is supposed to do. I don't know vb.net, maybe someone else can help, sorry.

 

vtpus = a method that takes a cstring named 'f' and returns an int.

 

1) A cstring named 'cbuf' that can hold 1024 characters is made.

2) Copy the characters in 'f' to 'cbuf'

3) Invoke vtProcessedTextOut(). Parameter 1 is the string you want to use, and parameter 2 is the length of the string you want to use.

4) return 0

 

Just so you know, that code u posted won't compile and if f is more than 1024 bytes, you'll get a buffer overflow.

 

for .net, you would make a method, 'vtputs', that returns an Int32 and takes a String named 'f'.

 

line1 = vtProcessedTextOut(f, f.Length)

line2 = return 0

  • 2 weeks later...
Posted

This should do the same thing, I don't know what vtProcessedTextOut is though, I'm treating it as a second procedure.

'The command ByVal creates a COPY of the original, ByRef gets an actual reference
Public Sub vtPuts(ByVal f() As Char)
vtProcessedTextOut(f, f.GetUpperBound(0))
End Sub

.Net allows software to be written for any version of Windows and not break like Unmanaged applications unless using Unmanaged procedures like APIs. If your program uses large amounts of memory but releases it when something else needs it, then what's the problem?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...