Visual C isn't a different language. The visual part refers to the fact that the IDE does things in a "visual" way ie place buttons on forms with point and click rather than coding positions manually.
It does come with some microsoft written extensions included. But if you code using the standards, it will compile with no problems.
If i download microsoft visual C , does it run/compile C code? (C code not visual C)?
yes
Reply:Yes. If you confine your coding to standard C, it will compile it as standard C. Most Microsoft extensions are flagged in the documentation.
Hope that answers your question.
Reply:If you use visual studio to create standard c programs then you start by creating a project as a console project.
Friday, July 31, 2009
Simple C code problem?
#include%26lt;stdio.h%26gt;
main()
{
message();
printf("\nCry, and you stop the monotomy");
}
message()
{
printf("\nSmile and world smiles with you....");
}
The error message
Call to undefined funtion "message" in funtion main()
Can u tell me where I am wrong
Simple C code problem?
You should declare the function before its use.
So this will be the correct format.
#include%26lt;stdio.h%26gt;
void message();
main()
{
message();
printf("\nCry, and you stop the monotomy");
}
void message()
{
printf("\nSmile and world smiles with you....");
}
Reply:I'm horrible with libraries or whatever. but it appears the %26lt;stdio.h%26gt; does not contain the function message();. Find out which library does and include it in the heading with stdio.h... what is message(); supposed to do? hope i helped
Reply:You haven't defined the function "message"
Simply delete that line or write a function for it before it is called.
main()
{
message();
printf("\nCry, and you stop the monotomy");
}
message()
{
printf("\nSmile and world smiles with you....");
}
The error message
Call to undefined funtion "message" in funtion main()
Can u tell me where I am wrong
Simple C code problem?
You should declare the function before its use.
So this will be the correct format.
#include%26lt;stdio.h%26gt;
void message();
main()
{
message();
printf("\nCry, and you stop the monotomy");
}
void message()
{
printf("\nSmile and world smiles with you....");
}
Reply:I'm horrible with libraries or whatever. but it appears the %26lt;stdio.h%26gt; does not contain the function message();. Find out which library does and include it in the heading with stdio.h... what is message(); supposed to do? hope i helped
Reply:You haven't defined the function "message"
Simply delete that line or write a function for it before it is called.
Can anybody provide me the pinball source code in 'c'?
Pinball source code in 'c'
Can anybody provide me the pinball source code in 'c'?
This is vb code
http://www.devdos.com/vb/Visual_Basic.sh...
use this utility to transform to c:
http://ask.support.microsoft.com/kb/2163...
Can anybody provide me the pinball source code in 'c'?
This is vb code
http://www.devdos.com/vb/Visual_Basic.sh...
use this utility to transform to c:
http://ask.support.microsoft.com/kb/2163...
Visual Basic code to C# Code?
Dim crReportDocument As World_Sales_Report
Dim crExportOptions As ExportOptions
Dim crDiskFileDestinationOptions As DiskFileDestinationOptions
Visual Basic code to C# Code?
VB syntax:
Dim %26lt;variable name%26gt; as %26lt;type%26gt;
C# syntax:
%26lt;type%26gt; %26lt;variable name%26gt;;
so the VB code in C# is:
World_Sales_Report crReportDocument;
ExportOptions crExportOptions;
DiskFileDestinationOptions crDiskFileDestinationOptions;
Reply:World_Sales_Report crReportDocument;
ExportOptions crExportOptions;
DiskFileDestinationOptions crDiskFileDestinationOptions ;
Hope this helps.
dogwood
Dim crExportOptions As ExportOptions
Dim crDiskFileDestinationOptions As DiskFileDestinationOptions
Visual Basic code to C# Code?
VB syntax:
Dim %26lt;variable name%26gt; as %26lt;type%26gt;
C# syntax:
%26lt;type%26gt; %26lt;variable name%26gt;;
so the VB code in C# is:
World_Sales_Report crReportDocument;
ExportOptions crExportOptions;
DiskFileDestinationOptions crDiskFileDestinationOptions;
Reply:World_Sales_Report crReportDocument;
ExportOptions crExportOptions;
DiskFileDestinationOptions crDiskFileDestinationOptions ;
Hope this helps.
dogwood
Pls help me to have a source code in C++ that the input is user's birth year output is coressponding horoscope
Input: user's birth year
output: Chinese horoscope with corresponding elements
source code in c++
Pls help me to have a source code in C++ that the input is user's birth year output is coressponding horoscope
This is based on the info on the wikipedia page. Don't know if you need the extra heavenly/earthly fields.
#include %26lt;iostream%26gt;
using namespace std;
int main(int argc, char **argv)
{
int yr;
cin %26gt;%26gt; yr;
cout %26lt;%26lt; (((yr%2)==0)?"Yang ":"Yin ") ;
switch ((yr%10)/2)
{
case 0: cout %26lt;%26lt; "Metal"; break;
case 1: cout %26lt;%26lt; "Water"; break;
case 2: cout %26lt;%26lt; "Wood"; break;
case 3: cout %26lt;%26lt; "Fire"; break;
case 4: cout %26lt;%26lt; "Earth"; break;
}
cout %26lt;%26lt; ",";
switch (yr%12)
{
case 0: cout %26lt;%26lt; "Monkey"; break;
case 1: cout %26lt;%26lt; "Rooster"; break;
case 2: cout %26lt;%26lt; "Dog"; break;
case 3: cout %26lt;%26lt; "Boar"; break;
case 4: cout %26lt;%26lt; "Rat"; break;
case 5: cout %26lt;%26lt; "Ox"; break;
case 6: cout %26lt;%26lt; "Tiger"; break;
case 7: cout %26lt;%26lt; "Rabbit"; break;
case 8: cout %26lt;%26lt; "Dragon"; break;
case 9: cout %26lt;%26lt; "Snake"; break;
case 10: cout %26lt;%26lt; "Horse"; break;
case 11: cout %26lt;%26lt; "Sheep"; break;
}
cout %26lt;%26lt; endl;
return 0;
}
Reply:You will not find it anywhere. You may contact a C++ expert to code it for you. Check websites like http://oktutorial.com/
output: Chinese horoscope with corresponding elements
source code in c++
Pls help me to have a source code in C++ that the input is user's birth year output is coressponding horoscope
This is based on the info on the wikipedia page. Don't know if you need the extra heavenly/earthly fields.
#include %26lt;iostream%26gt;
using namespace std;
int main(int argc, char **argv)
{
int yr;
cin %26gt;%26gt; yr;
cout %26lt;%26lt; (((yr%2)==0)?"Yang ":"Yin ") ;
switch ((yr%10)/2)
{
case 0: cout %26lt;%26lt; "Metal"; break;
case 1: cout %26lt;%26lt; "Water"; break;
case 2: cout %26lt;%26lt; "Wood"; break;
case 3: cout %26lt;%26lt; "Fire"; break;
case 4: cout %26lt;%26lt; "Earth"; break;
}
cout %26lt;%26lt; ",";
switch (yr%12)
{
case 0: cout %26lt;%26lt; "Monkey"; break;
case 1: cout %26lt;%26lt; "Rooster"; break;
case 2: cout %26lt;%26lt; "Dog"; break;
case 3: cout %26lt;%26lt; "Boar"; break;
case 4: cout %26lt;%26lt; "Rat"; break;
case 5: cout %26lt;%26lt; "Ox"; break;
case 6: cout %26lt;%26lt; "Tiger"; break;
case 7: cout %26lt;%26lt; "Rabbit"; break;
case 8: cout %26lt;%26lt; "Dragon"; break;
case 9: cout %26lt;%26lt; "Snake"; break;
case 10: cout %26lt;%26lt; "Horse"; break;
case 11: cout %26lt;%26lt; "Sheep"; break;
}
cout %26lt;%26lt; endl;
return 0;
}
Reply:You will not find it anywhere. You may contact a C++ expert to code it for you. Check websites like http://oktutorial.com/
C# code for scanning an attachment with an antivirus( in a Intranet Mailing system)?
I am working on a intranet mailing system for an organization...can any one plz help me in embedding an antivirus patch file which should be used for scanning the attachment of a mail
thanks %26amp; regards
C# code for scanning an attachment with an antivirus( in a Intranet Mailing system)?
Does not look easy, may be you can contact a C# expert live at website like http://askexpert.info/ .
Reply:There's no easy way to do this with pure C#. If you have an antivirus running on your server, it should intercept a file upon upload and quarantine it. After it does, a check to File.Exists() will tell you if it was uploaded and remains in your upload directory. If not, you can always check for it wherever your anti-virus product stores quarantined files.
Take a look at this thread as well:
http://forums.asp.net/p/890935/956276.as...
thanks %26amp; regards
C# code for scanning an attachment with an antivirus( in a Intranet Mailing system)?
Does not look easy, may be you can contact a C# expert live at website like http://askexpert.info/ .
Reply:There's no easy way to do this with pure C#. If you have an antivirus running on your server, it should intercept a file upon upload and quarantine it. After it does, a check to File.Exists() will tell you if it was uploaded and remains in your upload directory. If not, you can always check for it wherever your anti-virus product stores quarantined files.
Take a look at this thread as well:
http://forums.asp.net/p/890935/956276.as...
C# code help...?
I need clarification on three types of loops, they all should sum the numbers from 1 to 10. like 1+2+3+4, etc...
one is a while() loop,
one is a for() loop
one is a do.. while() loop
C# code help...?
a while loop will first check it can execute. A do while loop will execute at least 1 time before it checks the condition if it can continue. A for loop will execute a set number of times from a starting number to an ending number
Reply:while(): runs till a condition is true or false
do while(): will run atleast once
for(): will run the number of times specified by you.
Reply:for(int i = 0; i %26gt; 10)
{
//code
}
Here is a for loop i forgot how to make other loops
Reply:int i;
int sum;
i = 1;
sum = 0;
while(i%26lt;=10)
{
sum += i;
i++;
}
sum = 0;
for(i=1;i%26lt;=10;i++)
{
sum += i;
}
i = 1;
sum = 0;
do
{
sum += i;
}while(i%26lt;=10);
one is a while() loop,
one is a for() loop
one is a do.. while() loop
C# code help...?
a while loop will first check it can execute. A do while loop will execute at least 1 time before it checks the condition if it can continue. A for loop will execute a set number of times from a starting number to an ending number
Reply:while(): runs till a condition is true or false
do while(): will run atleast once
for(): will run the number of times specified by you.
Reply:for(int i = 0; i %26gt; 10)
{
//code
}
Here is a for loop i forgot how to make other loops
Reply:int i;
int sum;
i = 1;
sum = 0;
while(i%26lt;=10)
{
sum += i;
i++;
}
sum = 0;
for(i=1;i%26lt;=10;i++)
{
sum += i;
}
i = 1;
sum = 0;
do
{
sum += i;
}while(i%26lt;=10);
C# code help: the Undo () method?
Hi, I am building a text editor, and I would like to undo the last thing done.
so, I used the Undo() method, but found it undoes everything changed, how can I set it so it only changes the LAST thing done?
C# code help: the Undo () method?
hai
u use the website www.codeproject.com
www.codeguru.com for the code for ur problem
Reply:Then this is your way to get the proper answer.
http://www.rentacoder.com/RentACoder/Sof...
Creative Professionals
redbud
so, I used the Undo() method, but found it undoes everything changed, how can I set it so it only changes the LAST thing done?
C# code help: the Undo () method?
hai
u use the website www.codeproject.com
www.codeguru.com for the code for ur problem
Reply:Then this is your way to get the proper answer.
http://www.rentacoder.com/RentACoder/Sof...
Creative Professionals
redbud
C++ code to write a binary file?
at a specific location, say, at byte offset x?
C++ code to write a binary file?
The two previous answers show you how to do it using C. In C++ you tend to use objects whenever possible. This page shows you how to write binary data files using streams:
http://courses.cs.vt.edu/~cs2604/fall00/...
Here is an example from the page:
#include %26lt;fstream.h%26gt;
...
class Data {
int key;
double value;
};
Data x;
Data *y = new Data[10];
fstream myFile ("data.bin", ios::in | ios::out | ios::binary);
// This is how you seek to a location or your offset
myFile.seekp (location1);
myFile.write ((char*)%26amp;x, sizeof (Data));
...
myFile.seekg (0);
myFile.read ((char*)y, sizeof (Data) * 10);
Reply:when you open file use 'b' option to specify its a binary open.
#include %26lt;stdio.h%26gt;
ret = fopen( name, options )
r
open for reading.
w
open for writing.
a
open for appending.
r+
open for both reading and writing. The stream will be positioned at the beginning of the file.
w+
open for both reading and writing. The stream will be created if it does not exist, and will be truncated if it does exist.
a+
open for both reading and writing. The stream will be positioned at the end of the existing file content.
rb
open for reading. The 'b' indicates binary data (as opposed to text); by default, this will be a sequential file in Media 4 format.
wb
open for writing. The 'b' indicates binary data.
ab
open for appending. The 'b' indicates binary data.
and Use seek/tellg to reach/get at the offset.
Reply:FILE * pFile = fopen("filename.ext", "r+b");
fseek(pFile, thePosition, SEEK_SET);
fwrite(pData, dataSize, dataCount, pFile);
fclose(pFile);
If you want to write past the end of the file or insert/delete data then you're going to have to load the file into memory, make the changes and then write out a new file.
C++ code to write a binary file?
The two previous answers show you how to do it using C. In C++ you tend to use objects whenever possible. This page shows you how to write binary data files using streams:
http://courses.cs.vt.edu/~cs2604/fall00/...
Here is an example from the page:
#include %26lt;fstream.h%26gt;
...
class Data {
int key;
double value;
};
Data x;
Data *y = new Data[10];
fstream myFile ("data.bin", ios::in | ios::out | ios::binary);
// This is how you seek to a location or your offset
myFile.seekp (location1);
myFile.write ((char*)%26amp;x, sizeof (Data));
...
myFile.seekg (0);
myFile.read ((char*)y, sizeof (Data) * 10);
Reply:when you open file use 'b' option to specify its a binary open.
#include %26lt;stdio.h%26gt;
ret = fopen( name, options )
r
open for reading.
w
open for writing.
a
open for appending.
r+
open for both reading and writing. The stream will be positioned at the beginning of the file.
w+
open for both reading and writing. The stream will be created if it does not exist, and will be truncated if it does exist.
a+
open for both reading and writing. The stream will be positioned at the end of the existing file content.
rb
open for reading. The 'b' indicates binary data (as opposed to text); by default, this will be a sequential file in Media 4 format.
wb
open for writing. The 'b' indicates binary data.
ab
open for appending. The 'b' indicates binary data.
and Use seek/tellg to reach/get at the offset.
Reply:FILE * pFile = fopen("filename.ext", "r+b");
fseek(pFile, thePosition, SEEK_SET);
fwrite(pData, dataSize, dataCount, pFile);
fclose(pFile);
If you want to write past the end of the file or insert/delete data then you're going to have to load the file into memory, make the changes and then write out a new file.
C++ code for recuritment process system -given criteria are checking vaccancy, interviewschedule,store appdet?
just ask ur question in detail how cud anyone answer like tat
C# Code Explanation?
using System;
class Base
{
public Base()
{
Console.WriteLine("Printing the Base constructor 1!");
}
public Base(int x)
{
Console.WriteLine("Printing the Base constructor 2!");
}
}
class Derived : Base
{
// implicitly call the Base(int x)
public Derived() : base(10)
{
Console.WriteLine("Printing the Derived constructor!");
}
}
class MyClass
{
public static void Main()
{
// Displays the Base constructor 2 followed by Derived Constructor
Derived d1 = new Derived();
Console.ReadLine();
}
}
C# Code Explanation?
http://www.dougv.com/blog/2006/12/06/int...
Reply:well ask this question on vbforums.com and u will get the answer in a sec.
good luck
Reply:see when ever a derived class object is created... it will first create a reference of the base class... then it will create the remainin part of the derived class....
so for the above the output wud be...
Printing the Base constructor 2!
Printing the Derived constructor!
since the base class is initiated first and then the derived class is !
class Base
{
public Base()
{
Console.WriteLine("Printing the Base constructor 1!");
}
public Base(int x)
{
Console.WriteLine("Printing the Base constructor 2!");
}
}
class Derived : Base
{
// implicitly call the Base(int x)
public Derived() : base(10)
{
Console.WriteLine("Printing the Derived constructor!");
}
}
class MyClass
{
public static void Main()
{
// Displays the Base constructor 2 followed by Derived Constructor
Derived d1 = new Derived();
Console.ReadLine();
}
}
C# Code Explanation?
http://www.dougv.com/blog/2006/12/06/int...
Reply:well ask this question on vbforums.com and u will get the answer in a sec.
good luck
Reply:see when ever a derived class object is created... it will first create a reference of the base class... then it will create the remainin part of the derived class....
so for the above the output wud be...
Printing the Base constructor 2!
Printing the Derived constructor!
since the base class is initiated first and then the derived class is !
C code for the sum of squares of n numbers?
in this program the user is asked to proceed or not ,if proceed it should go back to the loop and implement it if not it should exit.
C code for the sum of squares of n numbers?
#include%26lt;stdio.h%26gt;
#include%26lt;conio.h%26gt;
int main()
{
int total, num;
char ans;
total=0;
ans='y';
clrscr();
while((ans=='y')||(ans=='Y'))
{
printf("Enter a number ");
scanf("%d",%26amp;num);
total+=(num*num);
printf("Do you want to continue? \n");
ans=getch();
printf("%c\n",ans);
}
printf("Total is %d",total);
getch();
return 0;
}
sundew
C code for the sum of squares of n numbers?
#include%26lt;stdio.h%26gt;
#include%26lt;conio.h%26gt;
int main()
{
int total, num;
char ans;
total=0;
ans='y';
clrscr();
while((ans=='y')||(ans=='Y'))
{
printf("Enter a number ");
scanf("%d",%26amp;num);
total+=(num*num);
printf("Do you want to continue? \n");
ans=getch();
printf("%c\n",ans);
}
printf("Total is %d",total);
getch();
return 0;
}
sundew
C++ code to write a binary file?
at a specific location, say, at byte offset x?
C++ code to write a binary file?
The two previous answers show you how to do it using C. In C++ you tend to use objects whenever possible. This page shows you how to write binary data files using streams:
http://courses.cs.vt.edu/~cs2604/fall00/...
Here is an example from the page:
#include %26lt;fstream.h%26gt;
...
class Data {
int key;
double value;
};
Data x;
Data *y = new Data[10];
fstream myFile ("data.bin", ios::in | ios::out | ios::binary);
// This is how you seek to a location or your offset
myFile.seekp (location1);
myFile.write ((char*)%26amp;x, sizeof (Data));
...
myFile.seekg (0);
myFile.read ((char*)y, sizeof (Data) * 10);
Reply:when you open file use 'b' option to specify its a binary open.
#include %26lt;stdio.h%26gt;
ret = fopen( name, options )
r
open for reading.
w
open for writing.
a
open for appending.
r+
open for both reading and writing. The stream will be positioned at the beginning of the file.
w+
open for both reading and writing. The stream will be created if it does not exist, and will be truncated if it does exist.
a+
open for both reading and writing. The stream will be positioned at the end of the existing file content.
rb
open for reading. The 'b' indicates binary data (as opposed to text); by default, this will be a sequential file in Media 4 format.
wb
open for writing. The 'b' indicates binary data.
ab
open for appending. The 'b' indicates binary data.
and Use seek/tellg to reach/get at the offset.
Reply:FILE * pFile = fopen("filename.ext", "r+b");
fseek(pFile, thePosition, SEEK_SET);
fwrite(pData, dataSize, dataCount, pFile);
fclose(pFile);
If you want to write past the end of the file or insert/delete data then you're going to have to load the file into memory, make the changes and then write out a new file.
C++ code to write a binary file?
The two previous answers show you how to do it using C. In C++ you tend to use objects whenever possible. This page shows you how to write binary data files using streams:
http://courses.cs.vt.edu/~cs2604/fall00/...
Here is an example from the page:
#include %26lt;fstream.h%26gt;
...
class Data {
int key;
double value;
};
Data x;
Data *y = new Data[10];
fstream myFile ("data.bin", ios::in | ios::out | ios::binary);
// This is how you seek to a location or your offset
myFile.seekp (location1);
myFile.write ((char*)%26amp;x, sizeof (Data));
...
myFile.seekg (0);
myFile.read ((char*)y, sizeof (Data) * 10);
Reply:when you open file use 'b' option to specify its a binary open.
#include %26lt;stdio.h%26gt;
ret = fopen( name, options )
r
open for reading.
w
open for writing.
a
open for appending.
r+
open for both reading and writing. The stream will be positioned at the beginning of the file.
w+
open for both reading and writing. The stream will be created if it does not exist, and will be truncated if it does exist.
a+
open for both reading and writing. The stream will be positioned at the end of the existing file content.
rb
open for reading. The 'b' indicates binary data (as opposed to text); by default, this will be a sequential file in Media 4 format.
wb
open for writing. The 'b' indicates binary data.
ab
open for appending. The 'b' indicates binary data.
and Use seek/tellg to reach/get at the offset.
Reply:FILE * pFile = fopen("filename.ext", "r+b");
fseek(pFile, thePosition, SEEK_SET);
fwrite(pData, dataSize, dataCount, pFile);
fclose(pFile);
If you want to write past the end of the file or insert/delete data then you're going to have to load the file into memory, make the changes and then write out a new file.
C++ code for Fibonacci series?
Do you have to output it? Calculate it? Need a bit more of an explanation for that...however, I do remember something about recursives. We created the series using a recursive function.
C++ code for Fibonacci series?
Are you looking for a code sample? It should be easy to find. A Fibonacci series is pretty elementary coding.
Reply:Check out this link.
http://www.brpreiss.com/books/opus4/html...
C++ code for Fibonacci series?
Are you looking for a code sample? It should be easy to find. A Fibonacci series is pretty elementary coding.
Reply:Check out this link.
http://www.brpreiss.com/books/opus4/html...
C# code in fibonacci method?
I don't know C# but I have heard it is very simillar to Java. I am giving the Java code
int Fibonacci(int n)
{
int low=0, hi=1;
for(int i=1;i%26lt;n;i++)
{
int tempHi=hi;
hi=low+hi;
low=tempHi;
}
return hi;
}
}
Using recursion is not good. because recursive version is of order O(n^2) and has too much function call overhead.
While iterative version( my one) is O(n) that is linear time.
C# code in fibonacci method?
ALGORITHM 1A: BINARY RECURSION
#include %26lt;stdio.h%26gt; /* Required to use printf() */
/* Function f(n) returns the n'th Fibonacci number
* It uses ALGORITHM 1A: BINARY RECURSION
*/
unsigned int f(int n) {
return n%26lt;2 ? 1 : f(n-1)+f(n-2);
}
/* Function f_print(n) prints the n'th Fibonacci number */
void f_print(int n) {
printf("%dth Fibonacci number is %lu\n",n,f(n));
}
/* Function main() is the program entry point in C */
int main(void) {
f_print(46);
return 0;
}
int Fibonacci(int n)
{
int low=0, hi=1;
for(int i=1;i%26lt;n;i++)
{
int tempHi=hi;
hi=low+hi;
low=tempHi;
}
return hi;
}
}
Using recursion is not good. because recursive version is of order O(n^2) and has too much function call overhead.
While iterative version( my one) is O(n) that is linear time.
C# code in fibonacci method?
ALGORITHM 1A: BINARY RECURSION
#include %26lt;stdio.h%26gt; /* Required to use printf() */
/* Function f(n) returns the n'th Fibonacci number
* It uses ALGORITHM 1A: BINARY RECURSION
*/
unsigned int f(int n) {
return n%26lt;2 ? 1 : f(n-1)+f(n-2);
}
/* Function f_print(n) prints the n'th Fibonacci number */
void f_print(int n) {
printf("%dth Fibonacci number is %lu\n",n,f(n));
}
/* Function main() is the program entry point in C */
int main(void) {
f_print(46);
return 0;
}
C++ code for descrete fractional gaussian noise?
Most random number generators produce what is known as white noise. Mathematically this means:
%26lt;{epsilon}(t){epsilon}(t')%26gt; = {delta} (t - t')
where the right hand side is a Dirac delta function. What this really means is that the successive values of the random numbers are not correlated with each other. At the same time the probability distribution of the random numbers is given by a Gaussian, which means the numbers around a central-mean are more likely than others:
P({epsilon}) = 1/(sqrt(2{pi}{sigma}) exp[-({epsilon}-{epsilon}0)^2/2{sigma}^2...
The central mean {epsilon}0 is usually taken to be zero. The typical random number generator that comes with a compiler is one that is nominally "white", that is one with a probability distribution that is flat and not a Gaussian. Obtaining Gaussian random numbers from a a flat random number generator is achieved in an elegant form using the Box-Mueller algorithm. This is illustrated very nicely in Numerical Recipes (Press, Teukolsky, Vetterling and Falnnery, Cambdrige Univ. Press). Here we give a modification of this same algorithm based on the work by Fox, Gatland, Roy and Vemuri (Physical Review vol A38, p.5938, 1988). The intent here is to generate random numbers that are correlated between successive values with an exponentially decaying memory of {tau}.
%26lt;{epsilon}(t){epsilon}(t')%26gt; = (1/{tau}) exp (-|t-t'|/{tau})
The routine requires a flat random number generator which here is named RAN1. You can change this name as necessary but it refers to the fast algorithm given in Numerical Recipes.
The random number generator routine is called CGAUSS and it must be initialized in CGAUS0 which also initializes RAN1. The routine will also generate white noise when the memory {tau} is set to zero. The driver routine is one simply to calculate the correlation function given in the last equation above, and the
Without much rigorous justification the same routine could be coaxed to generate a noise series with more than one memory length. This is possible because the correlation time enters only in terms of two parameters (CAPE and L1ME2) which are fixed by CGAUS0. So if we flip these parameters between two sets calculated each for a different memory length, we can generate a noise series with a short term and a long term memory. The flipping would be decided based on a flat random number (say via RAN1). The multiple memory effect would appear as a change of slope in the graph in moving from short time delays to longer
C++ code for descrete fractional gaussian noise?
Do a google search. Otherwise, write it yourself.
Reply:ok
baby breath
%26lt;{epsilon}(t){epsilon}(t')%26gt; = {delta} (t - t')
where the right hand side is a Dirac delta function. What this really means is that the successive values of the random numbers are not correlated with each other. At the same time the probability distribution of the random numbers is given by a Gaussian, which means the numbers around a central-mean are more likely than others:
P({epsilon}) = 1/(sqrt(2{pi}{sigma}) exp[-({epsilon}-{epsilon}0)^2/2{sigma}^2...
The central mean {epsilon}0 is usually taken to be zero. The typical random number generator that comes with a compiler is one that is nominally "white", that is one with a probability distribution that is flat and not a Gaussian. Obtaining Gaussian random numbers from a a flat random number generator is achieved in an elegant form using the Box-Mueller algorithm. This is illustrated very nicely in Numerical Recipes (Press, Teukolsky, Vetterling and Falnnery, Cambdrige Univ. Press). Here we give a modification of this same algorithm based on the work by Fox, Gatland, Roy and Vemuri (Physical Review vol A38, p.5938, 1988). The intent here is to generate random numbers that are correlated between successive values with an exponentially decaying memory of {tau}.
%26lt;{epsilon}(t){epsilon}(t')%26gt; = (1/{tau}) exp (-|t-t'|/{tau})
The routine requires a flat random number generator which here is named RAN1. You can change this name as necessary but it refers to the fast algorithm given in Numerical Recipes.
The random number generator routine is called CGAUSS and it must be initialized in CGAUS0 which also initializes RAN1. The routine will also generate white noise when the memory {tau} is set to zero. The driver routine is one simply to calculate the correlation function given in the last equation above, and the
Without much rigorous justification the same routine could be coaxed to generate a noise series with more than one memory length. This is possible because the correlation time enters only in terms of two parameters (CAPE and L1ME2) which are fixed by CGAUS0. So if we flip these parameters between two sets calculated each for a different memory length, we can generate a noise series with a short term and a long term memory. The flipping would be decided based on a flat random number (say via RAN1). The multiple memory effect would appear as a change of slope in the graph in moving from short time delays to longer
C++ code for descrete fractional gaussian noise?
Do a google search. Otherwise, write it yourself.
Reply:ok
baby breath
C++ code errors?
I recieve the following errors when I attempt to compile my program, please help.
pim.cpp: In function `void searchContacts(...)':
pim.cpp:112: `count' undeclared (first use this function)
pim.cpp:112: (Each undeclared identifier is reported only once
pim.cpp:112: for each function it appears in.)
pim.cpp:114: `contacts' undeclared (first use this function)
pim.cpp:114: parse error before `||'
pim.cpp:118: warning: implicit declaration of function `int print(...)'
pim.cpp:120: confused by earlier errors, bailing out
void searchContacts(PIM pim.contacts[], int count)
{
int matches = 0;
string name;
cout %26lt;%26lt; "\nEnter first or last name to find: ";
cin %26gt;%26gt; name;
for (int i = 0; i %26lt; count; i++)
{
if (contacts[i].firstname == name) || contacts[i].lastname == name))
{
matches++;
cout %26lt;%26lt; "\nContact " %26lt;%26lt; (i + 1) %26lt;%26lt; ":" %26lt;%26lt; endl;
print(contacts[i]);
}
}
cout %26lt;%26lt; "\nTotal number of matching contacts: " %26lt;%26lt; matches %26lt;%26lt; endl;
}
C++ code errors?
I can help you out, just name the compiler and version (gcc or microsoft c++)
Reply:for (int i = 0; i %26lt; count; i++)
you need to declare count:
const int count=10; or something like that
if (contacts[i].firstname == name
the array contacts is unknown, because your function declaration is broken. use:
void searchContacts (PIM contacts[]...)
or
void searchContacts (PIM *contacts...)
print (contacts[i])
The print function is unknown. You need a function declaration BEFORE searchContacts or in a header file.
pim.cpp: In function `void searchContacts(...)':
pim.cpp:112: `count' undeclared (first use this function)
pim.cpp:112: (Each undeclared identifier is reported only once
pim.cpp:112: for each function it appears in.)
pim.cpp:114: `contacts' undeclared (first use this function)
pim.cpp:114: parse error before `||'
pim.cpp:118: warning: implicit declaration of function `int print(...)'
pim.cpp:120: confused by earlier errors, bailing out
void searchContacts(PIM pim.contacts[], int count)
{
int matches = 0;
string name;
cout %26lt;%26lt; "\nEnter first or last name to find: ";
cin %26gt;%26gt; name;
for (int i = 0; i %26lt; count; i++)
{
if (contacts[i].firstname == name) || contacts[i].lastname == name))
{
matches++;
cout %26lt;%26lt; "\nContact " %26lt;%26lt; (i + 1) %26lt;%26lt; ":" %26lt;%26lt; endl;
print(contacts[i]);
}
}
cout %26lt;%26lt; "\nTotal number of matching contacts: " %26lt;%26lt; matches %26lt;%26lt; endl;
}
C++ code errors?
I can help you out, just name the compiler and version (gcc or microsoft c++)
Reply:for (int i = 0; i %26lt; count; i++)
you need to declare count:
const int count=10; or something like that
if (contacts[i].firstname == name
the array contacts is unknown, because your function declaration is broken. use:
void searchContacts (PIM contacts[]...)
or
void searchContacts (PIM *contacts...)
print (contacts[i])
The print function is unknown. You need a function declaration BEFORE searchContacts or in a header file.
C code for B-trees?
U can get it at
http://www.bluerwhite.org/btree/
But i wont suggest u going to the code directly.. First get som fundas clear abt them.. Preferably thru pseudocode and algorithms...Only then jump to the code
yucca
http://www.bluerwhite.org/btree/
But i wont suggest u going to the code directly.. First get som fundas clear abt them.. Preferably thru pseudocode and algorithms...Only then jump to the code
yucca
C++ code, please?
I want to make a program which prints the following series: 1, -4, 7, -10.......40.
Here's what I wrote up: It doesnt seem to work!! Please help!
#include %26lt;iostream.h%26gt;
int main()
{
double sgn;
for (int i = 1; i %26lt;= 40; i+=3)
{
i = i * sgn;
sgn = sgn * -1;
cout %26lt;%26lt; i %26lt;%26lt; endl;
}
system("PAUSE");
return 0;
}
C++ code, please?
You're not supposed to change the loop variable (i, in this case) inside the loop, and you should initialize sgn. Try this --I didn't test it, but tried to optimize is somewhat:
#include %26lt;iostream.h%26gt;
int main()
{
int sgn = 1;
for (int i = 1; i %26lt;= 40; i+=3)
{
cout %26lt;%26lt; i * sgn; %26lt;%26lt; endl;
sgn = -sgn;
}
system("PAUSE");
return 0;
}
Reply:"sgn" needs to be initialized before you use it ("sgn = 1;"). Also, when you multiply "i", your iterator, by "sgn", your sign, you are changing the length of the outer for loop and its operation drastically. Use a different variable to store the current series value separate from your iterator value (which should not be multiplied by -1).
Try this:
#include %26lt;iostream.h%26gt;
int main()
{
double sgn = -1;
for (int i = 1; i %26lt;= 40; i+=3)
{
sgn = sgn * -1;
cout %26lt;%26lt; (i * sgn) %26lt;%26lt; endl;
}
system("PAUSE");
return 0;
}
Reply:First off, yeah, don't change variable i. That is used for your loop and changing it inside the loop is a bad idea. Unless you need to for loop length but you don't.
Your sgn variable should be initialized before you use it definately. Give it a value before you begin using it that is:
sgn = 0;
You should have a way to know whether the variable should be outputed as a negative number or a positive number. One way is to use a boolean variable which is what I use the variable "isNegative" for. Now only when the negative number should be changed, it is. Your code as it is right now had you not been messing with the counter variable in your loop would have outputed every number as a negative number.
This will be better for you.
#include %26lt;iostream.h%26gt;
int main()
{
double sgn = 0; //initialize variable for later use
bool isNegative = false; //boolean variable to check negative
for (int i = 1; i %26lt;= 40; i+=3)
{
sgn = i;
if(isNegative)
{
sgn = -sgn; //if it's supposed to be negative, negativize it.
isNegative = false; //change variable for next number
}
else //number is already positive no need to change
isNegative = true; //change variable for next number
cout%26lt;%26lt;sgn%26lt;%26lt;endl; //output results
}
system("PAUSE");
return 0;
}
Hope that helps.
Here's what I wrote up: It doesnt seem to work!! Please help!
#include %26lt;iostream.h%26gt;
int main()
{
double sgn;
for (int i = 1; i %26lt;= 40; i+=3)
{
i = i * sgn;
sgn = sgn * -1;
cout %26lt;%26lt; i %26lt;%26lt; endl;
}
system("PAUSE");
return 0;
}
C++ code, please?
You're not supposed to change the loop variable (i, in this case) inside the loop, and you should initialize sgn. Try this --I didn't test it, but tried to optimize is somewhat:
#include %26lt;iostream.h%26gt;
int main()
{
int sgn = 1;
for (int i = 1; i %26lt;= 40; i+=3)
{
cout %26lt;%26lt; i * sgn; %26lt;%26lt; endl;
sgn = -sgn;
}
system("PAUSE");
return 0;
}
Reply:"sgn" needs to be initialized before you use it ("sgn = 1;"). Also, when you multiply "i", your iterator, by "sgn", your sign, you are changing the length of the outer for loop and its operation drastically. Use a different variable to store the current series value separate from your iterator value (which should not be multiplied by -1).
Try this:
#include %26lt;iostream.h%26gt;
int main()
{
double sgn = -1;
for (int i = 1; i %26lt;= 40; i+=3)
{
sgn = sgn * -1;
cout %26lt;%26lt; (i * sgn) %26lt;%26lt; endl;
}
system("PAUSE");
return 0;
}
Reply:First off, yeah, don't change variable i. That is used for your loop and changing it inside the loop is a bad idea. Unless you need to for loop length but you don't.
Your sgn variable should be initialized before you use it definately. Give it a value before you begin using it that is:
sgn = 0;
You should have a way to know whether the variable should be outputed as a negative number or a positive number. One way is to use a boolean variable which is what I use the variable "isNegative" for. Now only when the negative number should be changed, it is. Your code as it is right now had you not been messing with the counter variable in your loop would have outputed every number as a negative number.
This will be better for you.
#include %26lt;iostream.h%26gt;
int main()
{
double sgn = 0; //initialize variable for later use
bool isNegative = false; //boolean variable to check negative
for (int i = 1; i %26lt;= 40; i+=3)
{
sgn = i;
if(isNegative)
{
sgn = -sgn; //if it's supposed to be negative, negativize it.
isNegative = false; //change variable for next number
}
else //number is already positive no need to change
isNegative = true; //change variable for next number
cout%26lt;%26lt;sgn%26lt;%26lt;endl; //output results
}
system("PAUSE");
return 0;
}
Hope that helps.
C# code for login form?
What type of authentication do you plan to use?
Are you going to be using active directory or a database?
Is it web based or application based?
There are books out there that devote an entire chapter to this subject. There's a lot of information that needs to be known to setup authentication.
C# code for login form?
If you are using C# 2005 there is a login form that come with the system. Look in to the documentation it uses SQL 2005 and encrypts password / can import export stuff directly form active directory.
Are you going to be using active directory or a database?
Is it web based or application based?
There are books out there that devote an entire chapter to this subject. There's a lot of information that needs to be known to setup authentication.
C# code for login form?
If you are using C# 2005 there is a login form that come with the system. Look in to the documentation it uses SQL 2005 and encrypts password / can import export stuff directly form active directory.
C++ code ( 4 points to know if its a rectangle or not)?
Given 4 points, how will u figure out if its a rectangle or not?
C++ code ( 4 points to know if its a rectangle or not)?
The previous answers suggested by people before me are completely wrong. This is how you would do it:
1) Consider an Array A of 4 points.
2) Take the first point from the array A[0]
3) Compute the slopes between these points A[0],A[1] and A[0], A[2] and A[0],A[3] . Call these slopes m1, m2 and m3
4) Now If( m1*m2)==-1 then
{
if( A[3],A[1] *A[3], A[2]==-1)
cout %26lt;%26lt; "it is a rectangle/square";
else
cout %26lt;%26lt; "Sorry";
}
5) Note, you also have to similarly check for the other 2 cases. And you are done!
6) All the 3 cases fail, then it is not a rectangle/square
Reply:if the x is the same on vertice(point) pair 1,2 and pair 3,4 while the y of vertices 1,3 and 2,4 are the same then you have a rectangle.
Reply:find the slopes and distances.
Reply:if Point has coordinates x and y,
and rectangle(Point a, Point b, Point c, Point d) is the method
then it's a rectangle if (a.x==b.x %26amp;%26amp; b.y=c.y %26amp;%26amp; c.x==d.x %26amp;%26amp; d.y==a.y)
Reply:Check to see if there are two pairs of the same x coordinates as well as two pairs of the same y coordinates.
bool rectangle(x1, y1, x2, y2, x3, y3, x4, y4)
{
return (x1==x2 %26amp;%26amp; x3 == x4 %26amp;%26amp; y1 == y3 %26amp;%26amp; y2 == y4);
}
C++ code ( 4 points to know if its a rectangle or not)?
The previous answers suggested by people before me are completely wrong. This is how you would do it:
1) Consider an Array A of 4 points.
2) Take the first point from the array A[0]
3) Compute the slopes between these points A[0],A[1] and A[0], A[2] and A[0],A[3] . Call these slopes m1, m2 and m3
4) Now If( m1*m2)==-1 then
{
if( A[3],A[1] *A[3], A[2]==-1)
cout %26lt;%26lt; "it is a rectangle/square";
else
cout %26lt;%26lt; "Sorry";
}
5) Note, you also have to similarly check for the other 2 cases. And you are done!
6) All the 3 cases fail, then it is not a rectangle/square
Reply:if the x is the same on vertice(point) pair 1,2 and pair 3,4 while the y of vertices 1,3 and 2,4 are the same then you have a rectangle.
Reply:find the slopes and distances.
Reply:if Point has coordinates x and y,
and rectangle(Point a, Point b, Point c, Point d) is the method
then it's a rectangle if (a.x==b.x %26amp;%26amp; b.y=c.y %26amp;%26amp; c.x==d.x %26amp;%26amp; d.y==a.y)
Reply:Check to see if there are two pairs of the same x coordinates as well as two pairs of the same y coordinates.
bool rectangle(x1, y1, x2, y2, x3, y3, x4, y4)
{
return (x1==x2 %26amp;%26amp; x3 == x4 %26amp;%26amp; y1 == y3 %26amp;%26amp; y2 == y4);
}
C# code I need a full stop?
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Ch11Ex03yield
{
public class Primes
{
private long min;
public long max;
public Primes()
: this(2, 100)
{
}
public Primes(long i, long j)
{
if (i %26lt; 2)
{
min = 2;
}
min = i;
max = j;
}
public IEnumerator GetEnumerator()
{
for (long possiblePrime = min; possiblePrime %26lt;= max; possiblePrime++)
{
bool isPrime = true;
for (long possibleFactor = 2; possibleFactor %26lt;=
(long)Math.Floor(Math.Sqrt(possiblePrime... possibleFactor++)
{
long remainderAfterDivision = possiblePrime % possibleFactor;
if (remainderAfterDivision == 0)
{
C# code I need a full stop?
full stop? not really sure what that is, assuming you want the code to exit depending from a function or just out of a loop or to skip the current iteration in the loop.
you should use
break - stops execution
continue - skips current iteration
return - returns from calling method
chrysanthemum
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Ch11Ex03yield
{
public class Primes
{
private long min;
public long max;
public Primes()
: this(2, 100)
{
}
public Primes(long i, long j)
{
if (i %26lt; 2)
{
min = 2;
}
min = i;
max = j;
}
public IEnumerator GetEnumerator()
{
for (long possiblePrime = min; possiblePrime %26lt;= max; possiblePrime++)
{
bool isPrime = true;
for (long possibleFactor = 2; possibleFactor %26lt;=
(long)Math.Floor(Math.Sqrt(possiblePrime... possibleFactor++)
{
long remainderAfterDivision = possiblePrime % possibleFactor;
if (remainderAfterDivision == 0)
{
C# code I need a full stop?
full stop? not really sure what that is, assuming you want the code to exit depending from a function or just out of a loop or to skip the current iteration in the loop.
you should use
break - stops execution
continue - skips current iteration
return - returns from calling method
chrysanthemum
C++ code for removing duplicate values from a vector?
Just read each value store in aux variable and compare to the rest of the vector. If you can sort this vector first the duplicate values should be at the following positions. E.g.
11222233333
Otherwise you'll need to read every value and compare to the other ones.
11222233333
Otherwise you'll need to read every value and compare to the other ones.
"c++ code for money"?
Are you looking to get paid for programming in C++?
Are you looking to hire someone to code a C++ program for you?
Are you looking for functions/classes to represent money in C++?
Do try to be a *bit* more vague next time.
"c++ code for money"?
rentacoder.com
Reply:Please check the link below and see if it helps you. It is for converting a monetary value to a string.
Reply:What?
Reply:Right after the approach of Structured-Module Programming failed, since it held issues with the initialization (no constructors) among others and the Object-Oriented Programming began to be a closer approach to real world problems. Language C which is native on UNIX/LINUX OS Platforms was improved and changed in order to embrace this new approach, OOP (Object-Oriented Programming).
Bjarne Stroustrup made it after a lot of research in Software Engineering.
C++ is for the operator ++.
c = c + 1;
or
c++;
Some people have said it would be called ++C, instead.
for the programming logic.
++C means it first, add and later it is assigned.
Now time has gone by and AOP (Aspect-Oriented Programming)
is getting bigger and bigger.
Who knows? See Spring.
Hope it would be useful somehow.
Are you looking to hire someone to code a C++ program for you?
Are you looking for functions/classes to represent money in C++?
Do try to be a *bit* more vague next time.
"c++ code for money"?
rentacoder.com
Reply:Please check the link below and see if it helps you. It is for converting a monetary value to a string.
Reply:What?
Reply:Right after the approach of Structured-Module Programming failed, since it held issues with the initialization (no constructors) among others and the Object-Oriented Programming began to be a closer approach to real world problems. Language C which is native on UNIX/LINUX OS Platforms was improved and changed in order to embrace this new approach, OOP (Object-Oriented Programming).
Bjarne Stroustrup made it after a lot of research in Software Engineering.
C++ is for the operator ++.
c = c + 1;
or
c++;
Some people have said it would be called ++C, instead.
for the programming logic.
++C means it first, add and later it is assigned.
Now time has gone by and AOP (Aspect-Oriented Programming)
is getting bigger and bigger.
Who knows? See Spring.
Hope it would be useful somehow.
C++ code for counting number of pixels in an image?
If this is for a PictureBox,
pictureBox-%26gt;Size.Width;
pictureBox-%26gt;Size.Height;
Multiply those to get the total.
C++ code for counting number of pixels in an image?
Take a look at opencv
They are all kind of functions that can do what you want done real easy.
pictureBox-%26gt;Size.Width;
pictureBox-%26gt;Size.Height;
Multiply those to get the total.
C++ code for counting number of pixels in an image?
Take a look at opencv
They are all kind of functions that can do what you want done real easy.
C code - Acting weirdly Plz can anyone solve this?
#include%26lt;stdio.h%26gt;
struct test
{
unsigned short int a;
unsigned int b;
};
typedef struct test test;
int main()
{
printf("\n\nSize of test = %d\n",sizeof(test));
}
The expected answer was 6 but i am getting it as 8 !!!
I tried this with Microsoft VC++ 6.0 and GCC both give the size as 8...
Why is that so..
C code - Acting weirdly Plz can anyone solve this?
This is because of address alignment requirements of of variables, in the structure.
int starts on a multiple of 4 boundary
double starts on a multiple of 8 boundary and so on.
Try changing of the second variable in your structure as double and you will see the size as 16.
Reply:I tried this also with gcc and got the same result.
I tried a few experiments and have come to the conclusion that in a struct, the compiler will pack the struct in multiples of 32 bits (4, 8, 12, etc). However I tried making the struct entirely of 3 shorts, which gave me a size if 6. So if the largest data member is 2 bytes, then the compiler will pack the struct in multiples of two. Otherwise, the compiler will pack it in multiples of 4 bytes. e.g, a struct with a double and a short or int will have a size of 12.
In other words, it seems the problem is not with your code. The problem is one of compiler behavior.
Reply:I think in VC++ , all data type have 4 byte size, thats why u r getting 8 as answer, I am having a bit of knowledge that in VC++ compiler asign each data type 4 byte size so that compiler process faster. it access data as 4 byte at a time. that means if any data type is having size less than 4 byte than also it will be allocated into 4 byte of size.
Reply:The compiler inserts 2 dummy bytes between members ‘a’ and ‘b’.
The reason is that the compiler will align member variables to a multiple of the pack size or a multiple of the type size, whichever is smallest.
The default pack size in visual studio is 8 bytes.
daffodil
struct test
{
unsigned short int a;
unsigned int b;
};
typedef struct test test;
int main()
{
printf("\n\nSize of test = %d\n",sizeof(test));
}
The expected answer was 6 but i am getting it as 8 !!!
I tried this with Microsoft VC++ 6.0 and GCC both give the size as 8...
Why is that so..
C code - Acting weirdly Plz can anyone solve this?
This is because of address alignment requirements of of variables, in the structure.
int starts on a multiple of 4 boundary
double starts on a multiple of 8 boundary and so on.
Try changing of the second variable in your structure as double and you will see the size as 16.
Reply:I tried this also with gcc and got the same result.
I tried a few experiments and have come to the conclusion that in a struct, the compiler will pack the struct in multiples of 32 bits (4, 8, 12, etc). However I tried making the struct entirely of 3 shorts, which gave me a size if 6. So if the largest data member is 2 bytes, then the compiler will pack the struct in multiples of two. Otherwise, the compiler will pack it in multiples of 4 bytes. e.g, a struct with a double and a short or int will have a size of 12.
In other words, it seems the problem is not with your code. The problem is one of compiler behavior.
Reply:I think in VC++ , all data type have 4 byte size, thats why u r getting 8 as answer, I am having a bit of knowledge that in VC++ compiler asign each data type 4 byte size so that compiler process faster. it access data as 4 byte at a time. that means if any data type is having size less than 4 byte than also it will be allocated into 4 byte of size.
Reply:The compiler inserts 2 dummy bytes between members ‘a’ and ‘b’.
The reason is that the compiler will align member variables to a multiple of the pack size or a multiple of the type size, whichever is smallest.
The default pack size in visual studio is 8 bytes.
daffodil
C code problem?
#include%26lt;stdio.h%26gt;
void swapr(int, int);
void main()
{
int a=10,b=20;
swapr(%26amp;a,%26amp;b);
printf("\n a=%d b=%d",a,b);
}
void swapr(int*x,int *y)
{
int t;
t=*x;
*x=*y;
*y=t;
}
And error messages are
Compiling CAL_REF.CPP:
Error CAL_REF.CPP 6: Cannot convert 'int *' to 'int' in function main()
Error CAL_REF.CPP 6: Type mismatch in parameter 1 in call to 'swapr(int,int)' in function main()
Error CAL_REF.CPP 6: Cannot convert 'int *' to 'int' in function main()
Error CAL_REF.CPP 6: Type mismatch in parameter 2 in call to 'swapr(int,int)' in function main()
C code problem?
You made a mistake on the second line. You declared swapr as a function that takes two ints and returns nothing, but then you define swapr as a function that takes to pointers to ints and returns nothing.
So change the second line from
:: void swapr(int, int);
to
:: void swapr(int*, int*);
Reply:Try defining the variable 't' as integer pointer instead of integer.
Reply:you should just change the second line to void swapr(int*,int *)
Reply:#include%26lt;stdio.h%26gt;
void swapr(int, int); %26lt;- This is where the problem lies, you have declared a function that accepts two integer arguments where as you need to declare it as
void swapr(int *, int *); so it matches the function definition below the function main().
void main()
{
int a=10,b=20;
swapr(%26amp;a,%26amp;b);
printf("\n a=%d b=%d",a,b);
}
void swapr(int*x,int *y)
{
int t;
t=*x;
*x=*y;
*y=t;
}
void swapr(int, int);
void main()
{
int a=10,b=20;
swapr(%26amp;a,%26amp;b);
printf("\n a=%d b=%d",a,b);
}
void swapr(int*x,int *y)
{
int t;
t=*x;
*x=*y;
*y=t;
}
And error messages are
Compiling CAL_REF.CPP:
Error CAL_REF.CPP 6: Cannot convert 'int *' to 'int' in function main()
Error CAL_REF.CPP 6: Type mismatch in parameter 1 in call to 'swapr(int,int)' in function main()
Error CAL_REF.CPP 6: Cannot convert 'int *' to 'int' in function main()
Error CAL_REF.CPP 6: Type mismatch in parameter 2 in call to 'swapr(int,int)' in function main()
C code problem?
You made a mistake on the second line. You declared swapr as a function that takes two ints and returns nothing, but then you define swapr as a function that takes to pointers to ints and returns nothing.
So change the second line from
:: void swapr(int, int);
to
:: void swapr(int*, int*);
Reply:Try defining the variable 't' as integer pointer instead of integer.
Reply:you should just change the second line to void swapr(int*,int *)
Reply:#include%26lt;stdio.h%26gt;
void swapr(int, int); %26lt;- This is where the problem lies, you have declared a function that accepts two integer arguments where as you need to declare it as
void swapr(int *, int *); so it matches the function definition below the function main().
void main()
{
int a=10,b=20;
swapr(%26amp;a,%26amp;b);
printf("\n a=%d b=%d",a,b);
}
void swapr(int*x,int *y)
{
int t;
t=*x;
*x=*y;
*y=t;
}
C code help !!! Search for Folders in a given path !!!?
Hi i am writing an application where it has to get the list of all the files and folders under a given path...
Searching files i did with FindFirstFile and FindNextFile functions and is fine ....
But the problem is with searching the folders...
Can anyone tell me how to search for folders under a given path...
Are there any functions like i am using for 'file search' to get
the folder list...
Plz help...
I use VC++ 6.0 Compiler
C code help !!! Search for Folders in a given path !!!?
Try this
void FindFile(String* startingDir, String* fileName, ArrayList* foundFiles)
{
DirectoryInfo* dirInfo = new DirectoryInfo(startingDir);
if (dirInfo-%26gt;Exists) // make sure directory exists
{
FileInfo* files[] = dirInfo-%26gt;GetFiles();
for (int i = 0; i %26lt; files-%26gt;Length; i++)
{
String* currFileName = files[i]-%26gt;ToString();
if (0 == String::Compare(currFileName, fileName, true))
{
foundFiles-%26gt;Add(files[i]);
}
}
DirectoryInfo* subDirs[] = dirInfo-%26gt;GetDirectories();
for (int i = 0; i %26lt; subDirs-%26gt;Length; i++)
{
String* dirName = subDirs[i]-%26gt;FullName;
FindFile(dirName, fileName, foundFiles);
}
}
}
Reply:If you want/need to stick with C and not C++, see the example here:
http://www.siit.tu.ac.th/mdailey/class/2...
To only look at directories, in a portable way, you have to call stat() on each result and check with the S_ISDIR() macro e.g.:
char *fullpath = malloc(NAME_MAX+ 1);
while (NULL != (dirent = readdir(dir))) {
struct stat buf;
fullpath[0] = '\0';
if (wherelength + strlen(dirent-%26gt;d_name) + 1 %26gt; NAME_MAX) {
fprintf(stderr, "Path too long\n");
return 3;
}
strcpy(fullpath, where);
strcat(fullpath, "/");
strcat(fullpath, dirent-%26gt;d_name);
if(stat(fullpath, %26amp;buf)) {
fprintf(stderr, "stat: %d (%s)\n", errno, strerror(errno));
continue;
}
if (S_ISDIR(buf.st_mode)) {
printf("DIR: %s\n", dirent-%26gt;d_name);
}
Searching files i did with FindFirstFile and FindNextFile functions and is fine ....
But the problem is with searching the folders...
Can anyone tell me how to search for folders under a given path...
Are there any functions like i am using for 'file search' to get
the folder list...
Plz help...
I use VC++ 6.0 Compiler
C code help !!! Search for Folders in a given path !!!?
Try this
void FindFile(String* startingDir, String* fileName, ArrayList* foundFiles)
{
DirectoryInfo* dirInfo = new DirectoryInfo(startingDir);
if (dirInfo-%26gt;Exists) // make sure directory exists
{
FileInfo* files[] = dirInfo-%26gt;GetFiles();
for (int i = 0; i %26lt; files-%26gt;Length; i++)
{
String* currFileName = files[i]-%26gt;ToString();
if (0 == String::Compare(currFileName, fileName, true))
{
foundFiles-%26gt;Add(files[i]);
}
}
DirectoryInfo* subDirs[] = dirInfo-%26gt;GetDirectories();
for (int i = 0; i %26lt; subDirs-%26gt;Length; i++)
{
String* dirName = subDirs[i]-%26gt;FullName;
FindFile(dirName, fileName, foundFiles);
}
}
}
Reply:If you want/need to stick with C and not C++, see the example here:
http://www.siit.tu.ac.th/mdailey/class/2...
To only look at directories, in a portable way, you have to call stat() on each result and check with the S_ISDIR() macro e.g.:
char *fullpath = malloc(NAME_MAX+ 1);
while (NULL != (dirent = readdir(dir))) {
struct stat buf;
fullpath[0] = '\0';
if (wherelength + strlen(dirent-%26gt;d_name) + 1 %26gt; NAME_MAX) {
fprintf(stderr, "Path too long\n");
return 3;
}
strcpy(fullpath, where);
strcat(fullpath, "/");
strcat(fullpath, dirent-%26gt;d_name);
if(stat(fullpath, %26amp;buf)) {
fprintf(stderr, "stat: %d (%s)\n", errno, strerror(errno));
continue;
}
if (S_ISDIR(buf.st_mode)) {
printf("DIR: %s\n", dirent-%26gt;d_name);
}
C# Code, Help on Random/Next?
Random randNum = new Random();
randNum.Next(100);
still learning, When this runs, I get 0 as an answer everytime.?
I have randNum being declaired "static int radNum"
C# Code, Help on Random/Next?
Dude, you have to set it to something. Your object of class Random is just a random number *generator*. You're trying to reuse the same variable name.
Random r = new Random();
int randNum = r.Next(100);
Reply:the problem might be you aren't using any seed value. Set the seed value and than try the same again. Also use the variable to store the randNum.Next value. Keep chaging the seed value.
int seed = DateTime.Now.MilliSecond;
Random randNum = new Random(seed);
int a = randNum.Next(100);
randNum.Next(100);
still learning, When this runs, I get 0 as an answer everytime.?
I have randNum being declaired "static int radNum"
C# Code, Help on Random/Next?
Dude, you have to set it to something. Your object of class Random is just a random number *generator*. You're trying to reuse the same variable name.
Random r = new Random();
int randNum = r.Next(100);
Reply:the problem might be you aren't using any seed value. Set the seed value and than try the same again. Also use the variable to store the randNum.Next value. Keep chaging the seed value.
int seed = DateTime.Now.MilliSecond;
Random randNum = new Random(seed);
int a = randNum.Next(100);
C code question?
#include %26lt;stdio.h%26gt;
#include %26lt;stdlib.h%26gt;
int main ()
{
int i, n;
int *pointerData;
printf ("Enter number of items to be stored: ");
scanf ("%d", %26amp;i);
pointerData = (int*) calloc (i, sizeof(int));
if (pointerData==NULL)
exit (1);
for (n = 0; n %26lt; i; n++)
{
printf ("Enter number #%d: ", n);
scanf ("%d", %26amp;pointerData[ n ]);
}
printf ("You have entered: ");
for (n = 0; n %26lt; i; n++)
printf ("%d ", pointerData[ n ]);
free (pointerData);
system("pause");
return 0;
}
can somebody tell me when does the first if statement will occur?
I know that when *pointerData is NULL. But what would the user enter so that pointerData will become NULL.
thanks
C code question?
You might also do like this so you can get a visual clue as to what's going on:
if (pointerData==NULL)
{
printf("Memory allocation failed! Exiting program...\n");
exit (1);
}
Otherwise, I'd say this code is fairly well written. Another poster had an issue with your cast of calloc's (void *) of allocated memory to an (int *). IMO, all this does is silence a compiler warning, and shouldn't affect performance whatsoever. ANSI experts and purists will disagree--and probably for good reason--because someday, in some instance, it could bite you, yes. But in many years of programming experience, I haven't run into that instance yet. Opinion mode, "off". And good luck.
Oh! And to answer your question, "when does the first if statement will occur?" ... almost immediately after you enter a value at the prompt:
printf ("Enter number of items to be stored: ");
scanf ("%d", %26amp;i);
The code execution progresses top down from main(), and there are no loops or anything to significantly delay execution to the first if(), (except the wait for the user to enter a value). A microsecond after the user enters a value, I'd say, is when the first if() gets hit...
I see one more question, "But what would the user enter so that pointerData will become NULL"
Answer: any number that is too large for calloc() to be able to allocate memory for that many integers.
sizeof(int) is variable depending on implementation, but generally 2 to 4 bytes. Now, we're allocating n * sizeof(int), so number of bytes of memory requested could be 2 to 4 times greater than n...that's important.
But certainly, and generally, any value of n less than 1,000 should give no problem...unless you have a hundred other applications running, or something equally bizarre.
////////////////////EDIT//////////
Thumbs up for you, CatNip! Poster wasn't asking when if() executes, but when it's true.
Now, see? I should have been able to translate that question.... :-) Kudos...
Reply:if there isn't enough memory for the calloc() to allocate the amount of space requested, then it will return a null pointer.
Reply:pointerData is set by the calloc() call. If calloc fails, because, for instance, the computer is out of free memory, then pointerData will be NULL.
You should ALWAYS ALWAYS ALWAYS test the results of calloc or malloc for success.
Also, calloc and malloc's result should NOT be cast like this.
Reply:The 1st if statement will be true if one of the following happens:
1. The calloc fails. See the errno for the error value.
2. If either input parameter into calloc is 0, then it may return a Null or it may not. It depends on the implementation, in which case the 1st If statement may not be true.
hyacinth
#include %26lt;stdlib.h%26gt;
int main ()
{
int i, n;
int *pointerData;
printf ("Enter number of items to be stored: ");
scanf ("%d", %26amp;i);
pointerData = (int*) calloc (i, sizeof(int));
if (pointerData==NULL)
exit (1);
for (n = 0; n %26lt; i; n++)
{
printf ("Enter number #%d: ", n);
scanf ("%d", %26amp;pointerData[ n ]);
}
printf ("You have entered: ");
for (n = 0; n %26lt; i; n++)
printf ("%d ", pointerData[ n ]);
free (pointerData);
system("pause");
return 0;
}
can somebody tell me when does the first if statement will occur?
I know that when *pointerData is NULL. But what would the user enter so that pointerData will become NULL.
thanks
C code question?
You might also do like this so you can get a visual clue as to what's going on:
if (pointerData==NULL)
{
printf("Memory allocation failed! Exiting program...\n");
exit (1);
}
Otherwise, I'd say this code is fairly well written. Another poster had an issue with your cast of calloc's (void *) of allocated memory to an (int *). IMO, all this does is silence a compiler warning, and shouldn't affect performance whatsoever. ANSI experts and purists will disagree--and probably for good reason--because someday, in some instance, it could bite you, yes. But in many years of programming experience, I haven't run into that instance yet. Opinion mode, "off". And good luck.
Oh! And to answer your question, "when does the first if statement will occur?" ... almost immediately after you enter a value at the prompt:
printf ("Enter number of items to be stored: ");
scanf ("%d", %26amp;i);
The code execution progresses top down from main(), and there are no loops or anything to significantly delay execution to the first if(), (except the wait for the user to enter a value). A microsecond after the user enters a value, I'd say, is when the first if() gets hit...
I see one more question, "But what would the user enter so that pointerData will become NULL"
Answer: any number that is too large for calloc() to be able to allocate memory for that many integers.
sizeof(int) is variable depending on implementation, but generally 2 to 4 bytes. Now, we're allocating n * sizeof(int), so number of bytes of memory requested could be 2 to 4 times greater than n...that's important.
But certainly, and generally, any value of n less than 1,000 should give no problem...unless you have a hundred other applications running, or something equally bizarre.
////////////////////EDIT//////////
Thumbs up for you, CatNip! Poster wasn't asking when if() executes, but when it's true.
Now, see? I should have been able to translate that question.... :-) Kudos...
Reply:if there isn't enough memory for the calloc() to allocate the amount of space requested, then it will return a null pointer.
Reply:pointerData is set by the calloc() call. If calloc fails, because, for instance, the computer is out of free memory, then pointerData will be NULL.
You should ALWAYS ALWAYS ALWAYS test the results of calloc or malloc for success.
Also, calloc and malloc's result should NOT be cast like this.
Reply:The 1st if statement will be true if one of the following happens:
1. The calloc fails. See the errno for the error value.
2. If either input parameter into calloc is 0, then it may return a Null or it may not. It depends on the implementation, in which case the 1st If statement may not be true.
hyacinth
C++ code, how to write a value returned function to force the user to input an integer test score between...?
A value returned function to force the user to input an integer test score between 0 and 100 inclusive and then return that valid score.
C++ code, how to write a value returned function to force the user to input an integer test score between...?
int testScore()
{
int score=-1;
while(score%26gt;100 || score%26lt;0)
{
cout%26lt;%26lt;"You must enter a number between 0 and 100"%26lt;%26lt;endl;
cin%26gt;%26gt;score;
}
return score;
}
Reply:this is what it would be in C, I don't know C++
int get_test_score (void)
{
int test_score;
puts("Enter a test score");
scanf(" %d", %26amp;test_score);
if ((test_score %26lt; 0) || (test_score %26gt; 100))
{
get_test_score();
{
else
{
return test_score;
}
}
the languages are similar, I wouldn't be surprised if this works
C++ code, how to write a value returned function to force the user to input an integer test score between...?
int testScore()
{
int score=-1;
while(score%26gt;100 || score%26lt;0)
{
cout%26lt;%26lt;"You must enter a number between 0 and 100"%26lt;%26lt;endl;
cin%26gt;%26gt;score;
}
return score;
}
Reply:this is what it would be in C, I don't know C++
int get_test_score (void)
{
int test_score;
puts("Enter a test score");
scanf(" %d", %26amp;test_score);
if ((test_score %26lt; 0) || (test_score %26gt; 100))
{
get_test_score();
{
else
{
return test_score;
}
}
the languages are similar, I wouldn't be surprised if this works
C++ code please help?
http://rafb.net/p/zsAuBu37.html
check this out, any suggestions?
C++ code please help?
What help do you require? May be you can contact a C++ expert at websites like http://askexpert.info/
check this out, any suggestions?
C++ code please help?
What help do you require? May be you can contact a C++ expert at websites like http://askexpert.info/
C++ code to clear cache memory?
I need to copy a file from Removable disk, First time it copies from the Removable disk, next time it takes from Cache memory, But i want to always copy from Removable disk with out any reset, so i want to clear cache memory so that i can copy from Removable disk every time
C++ code to clear cache memory?
C programming code to clear cache memory maybe should search internet for codes
Reply:try out something related to fflush() function i suppose.
our try out c++ help related to device functions.
Reply:c++?
C++ code to clear cache memory?
C programming code to clear cache memory maybe should search internet for codes
Reply:try out something related to fflush() function i suppose.
our try out c++ help related to device functions.
Reply:c++?
M A C code what is my MAC code number?
I'm not sure if you mean MAC address
if you mean it so its ;
Short for Media Access Control address,
its usually a unique address identifies each node (ex : network card ,Modem , printer etc..) on the network
if you use windows XP you can get it as follows :
Click start then Run then type the command
ipconfig /all in the command prompt window
you should see some thing like this
http://www-dcn.fnal.gov/DCG-Docs/mac/200...
your MAC address is the physical address its the same
this link contains the ways how to get MAC in most of Operating Systems
http://www-dcn.fnal.gov/DCG-Docs/mac/ind...
M A C code what is my MAC code number?
There is two things this could be:
1. Each network device has an identification number that is unuque to it called a mac this is typically somethung like 21:a2:bc:34:34:df. It is used to identify the connection and typically you don't need to worry about it. If you want to know what it is do run %26gt; cmd and type ipconfig /all it is listed as physical address.
2. A MAC code is a code that you can get from your broadband suplier that allows you to transfer your service to another company. You get our ISP to generate this for you and give it to our new company, it is valid for 30 days, can only be used once and transfers your service in 7 days without any break in service. You just need to change log in details after change goes through. Typically this looks like BBIP2348232/FF34A usually starts BBIP but can start LL with different numbers for each one
Reply:MAC stands for Media Access Control. The MAC number is the built in "serial number" of your network interface card - it should be something like 00-60-97-11-CF-7F. ISTR that the first 2 or 3 pairs identify the manufacturer.
Reply:A MAC code number or MAC address, is the code number that was assigned to any hardware that you connect to your computer, it is unique to a specific object, i.e, a modem, a computer, a wireless device a printer, what ever , it is used normally by your network to identify the hardware that you have and to allow you to accept or not in the case of some else trying to use your network,it usually looks like this 00-DO-41-69-D6-17 , a series of numbers and letters, this is the MAC address of a PCMCIA wireless WiFi card for a lap top,
poppy
if you mean it so its ;
Short for Media Access Control address,
its usually a unique address identifies each node (ex : network card ,Modem , printer etc..) on the network
if you use windows XP you can get it as follows :
Click start then Run then type the command
ipconfig /all in the command prompt window
you should see some thing like this
http://www-dcn.fnal.gov/DCG-Docs/mac/200...
your MAC address is the physical address its the same
this link contains the ways how to get MAC in most of Operating Systems
http://www-dcn.fnal.gov/DCG-Docs/mac/ind...
M A C code what is my MAC code number?
There is two things this could be:
1. Each network device has an identification number that is unuque to it called a mac this is typically somethung like 21:a2:bc:34:34:df. It is used to identify the connection and typically you don't need to worry about it. If you want to know what it is do run %26gt; cmd and type ipconfig /all it is listed as physical address.
2. A MAC code is a code that you can get from your broadband suplier that allows you to transfer your service to another company. You get our ISP to generate this for you and give it to our new company, it is valid for 30 days, can only be used once and transfers your service in 7 days without any break in service. You just need to change log in details after change goes through. Typically this looks like BBIP2348232/FF34A usually starts BBIP but can start LL with different numbers for each one
Reply:MAC stands for Media Access Control. The MAC number is the built in "serial number" of your network interface card - it should be something like 00-60-97-11-CF-7F. ISTR that the first 2 or 3 pairs identify the manufacturer.
Reply:A MAC code number or MAC address, is the code number that was assigned to any hardware that you connect to your computer, it is unique to a specific object, i.e, a modem, a computer, a wireless device a printer, what ever , it is used normally by your network to identify the hardware that you have and to allow you to accept or not in the case of some else trying to use your network,it usually looks like this 00-DO-41-69-D6-17 , a series of numbers and letters, this is the MAC address of a PCMCIA wireless WiFi card for a lap top,
poppy
Can anyone get me the source code in C to count objects in a JPG image like Rice grains scattered in a square?
Can anyone get me the source code in C to count objects in a JPG image? the Image has a Square and some rice grains were scattered with in Square.
Can anyone get me the source code in C to count objects in a JPG image like Rice grains scattered in a square?
http://stommel.tamu.edu/~baum/linuxlist/...
http://www.eecs.berkeley.edu/Pubs/TechRp...
Reply:It is not simple as you think. You Decode the JPEG file to RAW data. Apply Image Processing algorithms and then process it.
I hope you may try to solve this problem with tools such as MATLAB.
Visit: http://www.mathworks.com/
Use Image Processing Tool Box
Gane
Can anyone get me the source code in C to count objects in a JPG image like Rice grains scattered in a square?
http://stommel.tamu.edu/~baum/linuxlist/...
http://www.eecs.berkeley.edu/Pubs/TechRp...
Reply:It is not simple as you think. You Decode the JPEG file to RAW data. Apply Image Processing algorithms and then process it.
I hope you may try to solve this problem with tools such as MATLAB.
Visit: http://www.mathworks.com/
Use Image Processing Tool Box
Gane
Can anyone convert this to a code in C++, please?
Can anyone convert the following to a code in C++, please?
void mergesort (int n, keytype S[])
{
if (n%26gt;1) {
const int h=[n/2], m = n - h;
int U[1 ..h], V[1 ..m];
copy S[1] through S[h] to U[1] through U[h];
copy S[h+1] through S[n] to V[1] through V[m];
mergesort(h, U);
mergesort(m, V);
merge (h, m, U, V, S);
}
}
Can anyone convert this to a code in C++, please?
This may help you:
http://www.algorithmist.com/index.php/Me...
void mergesort (int n, keytype S[])
{
if (n%26gt;1) {
const int h=[n/2], m = n - h;
int U[1 ..h], V[1 ..m];
copy S[1] through S[h] to U[1] through U[h];
copy S[h+1] through S[n] to V[1] through V[m];
mergesort(h, U);
mergesort(m, V);
merge (h, m, U, V, S);
}
}
Can anyone convert this to a code in C++, please?
This may help you:
http://www.algorithmist.com/index.php/Me...
Need c/c++ code to implement XOR using MSE algorithm?
its a problem on genetic algorithms..........urgently need some help.........
Need c/c++ code to implement XOR using MSE algorithm?
What is MSE algorithm? - may be you can contact a C expert live at website like http://askexpert.info/ .
Need c/c++ code to implement XOR using MSE algorithm?
What is MSE algorithm? - may be you can contact a C expert live at website like http://askexpert.info/ .
Where can i find free source code in c++ for a simple text editor?
please suggest me some address where i could find source code in c++ for a simple text editor ... i need to submit it for my project .. please help me
Where can i find free source code in c++ for a simple text editor?
just dial 040-39999999 and u will get the info from them.
Reply:I wrote a "simple" text editor some years ago... and, believe me, it was not that simple if you want to use only c++ and not the help of other components... I guess it will be done for windows, won't it (mine was for DOS). If you're going to use it in windows, I can give you this code:
(it's a really simple text editor, only contextual menu is available).
#include "windows.h"
#define x 10
#define y 10
#define CLASS_NAME "Win32AppDemo"
//////////////////////////////////////...
HWND This=0;
void SetWndRect(HWND c,int wx,int wy,int px,int py)
{
MoveWindow(c,px,py,wx,wy,1);
}
HWND CreateCtrl(char*clase,int subcl,HINSTANCE inst,HWND owner)
{ return CreateWindowEx(
WS_EX_TRANSPARENT,
clase,"",subcl|WS_CHILD|
WS_VISIBLE,
0,0,0,0,owner,NULL,inst,NULL);
}
RECT getRect(HWND c)
{
RECT r;
GetWindowRect(c,%26amp;r);
r.left-=3;r.right-=3;
r.top-=22;r.bottom-=22;
return r;
}
int ToRGB(int r,int g,int b)
{return RGB(r,g,b);}
//////////////////////////////////////...
RECT FRect={0,0,0,0};
int colorAct=ToRGB(128,128,128);
HWND wcombo=0;
HWND wtext=0;
HWND wprobar=0;
void MsgError(char* s )
{
MessageBox(This,s, CLASS_NAME, MB_APPLMODAL|MB_ICONERROR);
}
void OnPaint(HDC g, HWND w)
{
RECT r1;
GetClientRect(w,%26amp;r1);
r1.left += x ;r1.top +=y ;
r1.right -=x; r1.bottom -= y;
HBRUSH b1=
CreateSolidBrush(
ToRGB(0,0,255)
);
HBRUSH b2=
CreateSolidBrush(colorAct);
FrameRect(g,%26amp;r1,b1);
FillRect(g,%26amp;FRect,b2);
DeleteObject(b1);
DeleteObject(b2);
}
void OnCommand(HWND hwnd)
{
//Handle here commands:
}
void CreateForm(HINSTANCE hThisInstance, HWND This)
{
HWND tTarget=CreateCtrl("EDIT",
WS_BORDER |ES_MULTILINE|
WS_HSCROLL|
WS_VSCROLL,
hThisInstance,This);
SetClassLong (tTarget, GCL_HBRBACKGROUND, (long) GetStockObject(WHITE_BRUSH));
SetWindowText(tTarget,""),
SetParent(tTarget,This);
SetWndRect(
tTarget, 340,140,20,20
);
wtext=tTarget;
SetClassLong (This,
GCL_HBRBACKGROUND, (long)
GetStockObject(LTGRAY_BRUSH));
SetWindowText(This,"Text Editor");
SetWindowLong(This, GWL_STYLE, WS_CAPTION|WS_SYSMENU);
SendMessage(This,WM_SETICON, ICON_BIG,
(LPARAM)
LoadIcon(0,IDI_EXCLAMATION)
);
MoveWindow(This,0,0, 380,200,0);
ShowWindow(This,SW_SHOW);
}
//////////////////////////////////////...
LRESULT CALLBACK WinProc(HWND hwnd, UINT msg,WPARAM wP, LPARAM lP)
{
HDC dc=0;
switch (msg)
{
case WM_COMMAND:
{
OnCommand((HWND)lP);
break;
}
case WM_PAINT:
{
DefWindowProc(hwnd, msg, wP, lP);
dc=GetDC(hwnd);
OnPaint(dc,hwnd);
ReleaseDC(hwnd,dc);
break;
}
case WM_DESTROY:
{
PostQuitMessage(0);
break;
}
default: return DefWindowProc(hwnd, msg, wP, lP);
}
return 0;
}
int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil)
{
WNDCLASS wincl; MSG messages;
wincl.hInstance = hThisInstance;
wincl.lpszClassName = CLASS_NAME;
wincl.lpfnWndProc = WinProc;
wincl.style = CS_DBLCLKS;
wincl.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor(NULL, IDC_ARROW);
wincl.lpszMenuName = NULL;
wincl.cbClsExtra = 0;
wincl.cbWndExtra = 0;
wincl.hbrBackground = (HBRUSH) GetStockObject(LTGRAY_BRUSH);
if(!RegisterClass(%26amp;wincl)) return 0;
This=CreateWindow(
CLASS_NAME, // Classname
CLASS_NAME, // Title Text
WS_DLGFRAME |DS_MODALFRAME|DS_CENTER|
DS_3DLOOK|
WS_MINIMIZEBOX | WS_MAXIMIZEBOX |
WS_POPUP | WS_CAPTION | WS_SYSMENU,
CW_USEDEFAULT, // Windows decides the position
CW_USEDEFAULT, // where the window ends up on the screen
10, // The programs width
10 , // and height in pixels
HWND_DESKTOP, // The window is a child-window to desktop
NULL, // No menu
hThisInstance, // Program Instance handler
NULL // No Window Creation data
);
CreateForm(hThisInstance,
This);
while(GetMessage(%26amp;messages, NULL, 0, 0))
{
TranslateMessage(%26amp;messages);
DispatchMessage(%26amp;messages);
}
return messages.wParam;
}
Reply:dont knw about cpp, here's a link to a code in vc++ - should give you an idea
http://www.codeproject.com/useritems/tex...
hope this helps
cosmos
Where can i find free source code in c++ for a simple text editor?
just dial 040-39999999 and u will get the info from them.
Reply:I wrote a "simple" text editor some years ago... and, believe me, it was not that simple if you want to use only c++ and not the help of other components... I guess it will be done for windows, won't it (mine was for DOS). If you're going to use it in windows, I can give you this code:
(it's a really simple text editor, only contextual menu is available).
#include "windows.h"
#define x 10
#define y 10
#define CLASS_NAME "Win32AppDemo"
//////////////////////////////////////...
HWND This=0;
void SetWndRect(HWND c,int wx,int wy,int px,int py)
{
MoveWindow(c,px,py,wx,wy,1);
}
HWND CreateCtrl(char*clase,int subcl,HINSTANCE inst,HWND owner)
{ return CreateWindowEx(
WS_EX_TRANSPARENT,
clase,"",subcl|WS_CHILD|
WS_VISIBLE,
0,0,0,0,owner,NULL,inst,NULL);
}
RECT getRect(HWND c)
{
RECT r;
GetWindowRect(c,%26amp;r);
r.left-=3;r.right-=3;
r.top-=22;r.bottom-=22;
return r;
}
int ToRGB(int r,int g,int b)
{return RGB(r,g,b);}
//////////////////////////////////////...
RECT FRect={0,0,0,0};
int colorAct=ToRGB(128,128,128);
HWND wcombo=0;
HWND wtext=0;
HWND wprobar=0;
void MsgError(char* s )
{
MessageBox(This,s, CLASS_NAME, MB_APPLMODAL|MB_ICONERROR);
}
void OnPaint(HDC g, HWND w)
{
RECT r1;
GetClientRect(w,%26amp;r1);
r1.left += x ;r1.top +=y ;
r1.right -=x; r1.bottom -= y;
HBRUSH b1=
CreateSolidBrush(
ToRGB(0,0,255)
);
HBRUSH b2=
CreateSolidBrush(colorAct);
FrameRect(g,%26amp;r1,b1);
FillRect(g,%26amp;FRect,b2);
DeleteObject(b1);
DeleteObject(b2);
}
void OnCommand(HWND hwnd)
{
//Handle here commands:
}
void CreateForm(HINSTANCE hThisInstance, HWND This)
{
HWND tTarget=CreateCtrl("EDIT",
WS_BORDER |ES_MULTILINE|
WS_HSCROLL|
WS_VSCROLL,
hThisInstance,This);
SetClassLong (tTarget, GCL_HBRBACKGROUND, (long) GetStockObject(WHITE_BRUSH));
SetWindowText(tTarget,""),
SetParent(tTarget,This);
SetWndRect(
tTarget, 340,140,20,20
);
wtext=tTarget;
SetClassLong (This,
GCL_HBRBACKGROUND, (long)
GetStockObject(LTGRAY_BRUSH));
SetWindowText(This,"Text Editor");
SetWindowLong(This, GWL_STYLE, WS_CAPTION|WS_SYSMENU);
SendMessage(This,WM_SETICON, ICON_BIG,
(LPARAM)
LoadIcon(0,IDI_EXCLAMATION)
);
MoveWindow(This,0,0, 380,200,0);
ShowWindow(This,SW_SHOW);
}
//////////////////////////////////////...
LRESULT CALLBACK WinProc(HWND hwnd, UINT msg,WPARAM wP, LPARAM lP)
{
HDC dc=0;
switch (msg)
{
case WM_COMMAND:
{
OnCommand((HWND)lP);
break;
}
case WM_PAINT:
{
DefWindowProc(hwnd, msg, wP, lP);
dc=GetDC(hwnd);
OnPaint(dc,hwnd);
ReleaseDC(hwnd,dc);
break;
}
case WM_DESTROY:
{
PostQuitMessage(0);
break;
}
default: return DefWindowProc(hwnd, msg, wP, lP);
}
return 0;
}
int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil)
{
WNDCLASS wincl; MSG messages;
wincl.hInstance = hThisInstance;
wincl.lpszClassName = CLASS_NAME;
wincl.lpfnWndProc = WinProc;
wincl.style = CS_DBLCLKS;
wincl.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor(NULL, IDC_ARROW);
wincl.lpszMenuName = NULL;
wincl.cbClsExtra = 0;
wincl.cbWndExtra = 0;
wincl.hbrBackground = (HBRUSH) GetStockObject(LTGRAY_BRUSH);
if(!RegisterClass(%26amp;wincl)) return 0;
This=CreateWindow(
CLASS_NAME, // Classname
CLASS_NAME, // Title Text
WS_DLGFRAME |DS_MODALFRAME|DS_CENTER|
DS_3DLOOK|
WS_MINIMIZEBOX | WS_MAXIMIZEBOX |
WS_POPUP | WS_CAPTION | WS_SYSMENU,
CW_USEDEFAULT, // Windows decides the position
CW_USEDEFAULT, // where the window ends up on the screen
10, // The programs width
10 , // and height in pixels
HWND_DESKTOP, // The window is a child-window to desktop
NULL, // No menu
hThisInstance, // Program Instance handler
NULL // No Window Creation data
);
CreateForm(hThisInstance,
This);
while(GetMessage(%26amp;messages, NULL, 0, 0))
{
TranslateMessage(%26amp;messages);
DispatchMessage(%26amp;messages);
}
return messages.wParam;
}
Reply:dont knw about cpp, here's a link to a code in vc++ - should give you an idea
http://www.codeproject.com/useritems/tex...
hope this helps
cosmos
How to construct the code (computer program) in Turbo C for a word game?
How can I make a computer program (code) in C for a guessing game? The program is similar to Hangaroo, where the player tries to guess a predefined word given a certain clue like definition etc.. Three wrong letters end his chance to find the word.
How to construct the code (computer program) in Turbo C for a word game?
try www.gamedev.net
for game programming
How to construct the code (computer program) in Turbo C for a word game?
try www.gamedev.net
for game programming
Using Linked Lists and STL in C++ to write a code , Who can Help ?
I want to write the following code in C++ , who can help me or give me some example or pre-written code about this topic ???
you will implement a class template called polynomial using linked lists and instantiate it by int. Each node in the linked list represents a term (such as -7x5) in the polynomial and contains at least the following member variables: the degree(the degree of the term) and coeff (the nonzero coefficient of the term). Note that you should only store nonzero coefficients. This means that if a coefficient goes to zero as a result of any operation, you must make sure that you delete that node.
In addition, you must make sure that the terms in the linked list are arranged in increasing order of their degree. Thus, the linked list corresponding to polynomial q(x) defined above must have nodes in the following order: node 1 representing term -5, node 2 representing the term 6x3, and node 3 representing the term -7x5.
Using Linked Lists and STL in C++ to write a code , Who can Help ?
I won't write the whole thing for you, but here is reasonable starting methodology for this type of problem :
// Begin Code
#include %26lt;list.h%26gt;
// Polynomial term definition ... you can use a class or typedef it
// instead if you'd prefer.
struct Polynomial_Term
{
int coefficient;
int exponent;
};
// Polynomial type definition using the list template of the STL.
typedef list%26lt;struct Polynomial_Term%26gt; Polynomial;
// End Code
So you'll declare a local variable of type Polynomial ... loop through adding your nodes using the list template methods (possibly tossing 0 coefficient terms at this stage before adding them to the Polynomial) ... then sort the Polynomial using the list template method and a sorting routine supplied by you (compare the exponents of both terms).
You can see the list template's header file in your compiler's includes ... but the STL headers are a bit messy and cumbersome. If you need resources to help you understand what methods are available and how to properly use them, do a Google search for "C++ STL list template".
you will implement a class template called polynomial using linked lists and instantiate it by int. Each node in the linked list represents a term (such as -7x5) in the polynomial and contains at least the following member variables: the degree(the degree of the term) and coeff (the nonzero coefficient of the term). Note that you should only store nonzero coefficients. This means that if a coefficient goes to zero as a result of any operation, you must make sure that you delete that node.
In addition, you must make sure that the terms in the linked list are arranged in increasing order of their degree. Thus, the linked list corresponding to polynomial q(x) defined above must have nodes in the following order: node 1 representing term -5, node 2 representing the term 6x3, and node 3 representing the term -7x5.
Using Linked Lists and STL in C++ to write a code , Who can Help ?
I won't write the whole thing for you, but here is reasonable starting methodology for this type of problem :
// Begin Code
#include %26lt;list.h%26gt;
// Polynomial term definition ... you can use a class or typedef it
// instead if you'd prefer.
struct Polynomial_Term
{
int coefficient;
int exponent;
};
// Polynomial type definition using the list template of the STL.
typedef list%26lt;struct Polynomial_Term%26gt; Polynomial;
// End Code
So you'll declare a local variable of type Polynomial ... loop through adding your nodes using the list template methods (possibly tossing 0 coefficient terms at this stage before adding them to the Polynomial) ... then sort the Polynomial using the list template method and a sorting routine supplied by you (compare the exponents of both terms).
You can see the list template's header file in your compiler's includes ... but the STL headers are a bit messy and cumbersome. If you need resources to help you understand what methods are available and how to properly use them, do a Google search for "C++ STL list template".
I want to develop a code with c++ to shut down windows xp can any one help me out plz!?
iam running windows xp sp2 and i wnat to develop a code with c++ that will shut down my system.
I want to develop a code with c++ to shut down windows xp can any one help me out plz!?
hello my friend.
I don't know what kind of compiler you use to write your c++ program. we have a function in c++ that the name is system().
by this function you can easily do all of the command prompts code in your projects. so you can use shutdown code in this function.
i will copy the shutdown parameters for you:
Usage: shutdown [/i | /l | /s | /r | /g | /a | /p | /h | /e] [/f]
[/m \\computer][/t xxx][/d [p|u:]xx:yy [/c "comment"]]
No args Display help. This is the same as typing /?.
/? Display help. This is the same as not typing any options.
/i Display the graphical user interface (GUI).
This must be the first option.
/l Log off. This cannot be used with /m or /d options.
/s Shutdown the computer.
/r Shutdown and restart the computer.
/g Shutdown and restart the computer. After the system is
rebooted, restart any registered applications.
/a Abort a system shutdown.
This can only be used during the time-out period.
/p Turn off the local computer with no time-out or warning.
Can be used with /d and /f options.
/h Hibernate the local computer.
Can be used with the /f option.
/e Document the reason for an unexpected shutdown of a computer.
/m \\computer Specify the target computer.
/t xxx Set the time-out period before shutdown to xxx seconds.
The valid range is 0-600, with a default of 30.
Using /t xxx implies the /f option.
/c "comment" Comment on the reason for the restart or shutdown.
Maximum of 512 characters allowed.
/f Force running applications to close without forewarning users.
/f is automatically set when used in conjunction with /t xxx.
/d [p|u:]xx:yy Provide the reason for the restart or shutdown.
p indicates that the restart or shutdown is planned.
u indicates that the reason is user defined.
if neither p nor u is specified the restart or shutdown is unpl
anned.
xx is the major reason number (positive integer less than 256).
yy is the minor reason number (positive integer less than 65536).
and here is a sample of shutdown code in vs 2005:
#include "stdafx.h"
#include "iostream"
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
cout%26lt;%26lt;"amir";
system("shutdown -s");
return 0;
}
i hope that it will help you
Reply:Windows XP has a shutdown.exe which you can invoke. Alternatively, there is a commandline argument from rundll32 which also facilitates shutdown.
Reply:The function is called ExitWindowsEx. The msdn link is below. I have also added a link to an example code.
I want to develop a code with c++ to shut down windows xp can any one help me out plz!?
hello my friend.
I don't know what kind of compiler you use to write your c++ program. we have a function in c++ that the name is system().
by this function you can easily do all of the command prompts code in your projects. so you can use shutdown code in this function.
i will copy the shutdown parameters for you:
Usage: shutdown [/i | /l | /s | /r | /g | /a | /p | /h | /e] [/f]
[/m \\computer][/t xxx][/d [p|u:]xx:yy [/c "comment"]]
No args Display help. This is the same as typing /?.
/? Display help. This is the same as not typing any options.
/i Display the graphical user interface (GUI).
This must be the first option.
/l Log off. This cannot be used with /m or /d options.
/s Shutdown the computer.
/r Shutdown and restart the computer.
/g Shutdown and restart the computer. After the system is
rebooted, restart any registered applications.
/a Abort a system shutdown.
This can only be used during the time-out period.
/p Turn off the local computer with no time-out or warning.
Can be used with /d and /f options.
/h Hibernate the local computer.
Can be used with the /f option.
/e Document the reason for an unexpected shutdown of a computer.
/m \\computer Specify the target computer.
/t xxx Set the time-out period before shutdown to xxx seconds.
The valid range is 0-600, with a default of 30.
Using /t xxx implies the /f option.
/c "comment" Comment on the reason for the restart or shutdown.
Maximum of 512 characters allowed.
/f Force running applications to close without forewarning users.
/f is automatically set when used in conjunction with /t xxx.
/d [p|u:]xx:yy Provide the reason for the restart or shutdown.
p indicates that the restart or shutdown is planned.
u indicates that the reason is user defined.
if neither p nor u is specified the restart or shutdown is unpl
anned.
xx is the major reason number (positive integer less than 256).
yy is the minor reason number (positive integer less than 65536).
and here is a sample of shutdown code in vs 2005:
#include "stdafx.h"
#include "iostream"
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
cout%26lt;%26lt;"amir";
system("shutdown -s");
return 0;
}
i hope that it will help you
Reply:Windows XP has a shutdown.exe which you can invoke. Alternatively, there is a commandline argument from rundll32 which also facilitates shutdown.
Reply:The function is called ExitWindowsEx. The msdn link is below. I have also added a link to an example code.
Someone know if C++ code can be combined with flash codes?
Hi, im about to write my own emulators and i want to include some animations to it, such as introducing a cartridges or disks
in an animated console.
The problem is that i dont know how to combine both codes
Someone know if C++ code can be combined with flash codes?
Actually theres a technique to it. You can't just 'merge' per say. Actionscript and C++ are two different languages.
What you have to do is somehow transfer information between the two languages. Information can be transfer through files, database, registry, global variables, API, and other techniques.
online florists
in an animated console.
The problem is that i dont know how to combine both codes
Someone know if C++ code can be combined with flash codes?
Actually theres a technique to it. You can't just 'merge' per say. Actionscript and C++ are two different languages.
What you have to do is somehow transfer information between the two languages. Information can be transfer through files, database, registry, global variables, API, and other techniques.
online florists
Help needed writing this C language, i need one line of code in C language fole pat c please help.?
a) Write a function that will return a random double number. The function takes two parameters (both integers). The first parameter is the maximum whole-number value that the number can be (the minimum is 0.) The second parameter is how many places of random precision the number must have.
double randDub( intwhole, int precision)
{
double val;
int decOutcomes = pow(10, precision);
int totalOutcomes = whole*decOutcomes;
val= rand() % total outcomes;
return val/decOutcomes;
}
b) Write a line of code that will call the function you just wrote above and ask it to generate a random number from 0-100 with two places of precision, saving the return value in a variable (declare it) named ran.
ran = randDub(100,2);
c) Print the value of ran to two places.
printf(
Help needed writing this C language, i need one line of code in C language fole pat c please help.?
This is the line you want:
printf("%.2f", ran);
add a \n after the f if you want a carriage return.
The ".2" portion tells printf that you want precision of two and the "f" portion says the variable that you want to print is either a float or a double.
I hope this answers your question.
Reply:That's pretty simple. You should be able to work that out yourself, just look up printf in help.
double randDub( intwhole, int precision)
{
double val;
int decOutcomes = pow(10, precision);
int totalOutcomes = whole*decOutcomes;
val= rand() % total outcomes;
return val/decOutcomes;
}
b) Write a line of code that will call the function you just wrote above and ask it to generate a random number from 0-100 with two places of precision, saving the return value in a variable (declare it) named ran.
ran = randDub(100,2);
c) Print the value of ran to two places.
printf(
Help needed writing this C language, i need one line of code in C language fole pat c please help.?
This is the line you want:
printf("%.2f", ran);
add a \n after the f if you want a carriage return.
The ".2" portion tells printf that you want precision of two and the "f" portion says the variable that you want to print is either a float or a double.
I hope this answers your question.
Reply:That's pretty simple. You should be able to work that out yourself, just look up printf in help.
I want c code for finding minimal spanning tree. only c code. please mail it ti hurryforme@yahoo.com?
You may contact a C expert at http://askexpert.info/
I want c code for finding minimal spanning tree. only c code. please mail it ti hurryforme@yahoo.com?
You have the algorithm here http://en.wikipedia.org/wiki/Minimum_spa...
I want c code for finding minimal spanning tree. only c code. please mail it ti hurryforme@yahoo.com?
You have the algorithm here http://en.wikipedia.org/wiki/Minimum_spa...
I need any small game's source code in c or c++.. please help?
i need the source code in c or c++ for any small game.. very urgent please help!!!
I need any small game's source code in c or c++.. please help?
Let me welcome you to the world of "open source" software, most of which may be written in a "C" variant. An example of a product for which you can download the source code is http://prdownload.berlios.de/supertuxkar...
Reply:Sunil my friend I dont have time to write a code for you but this link will help you
http://www.google.co.uk/search?hl=en%26amp;sa=...
I need any small game's source code in c or c++.. please help?
Let me welcome you to the world of "open source" software, most of which may be written in a "C" variant. An example of a product for which you can download the source code is http://prdownload.berlios.de/supertuxkar...
Reply:Sunil my friend I dont have time to write a code for you but this link will help you
http://www.google.co.uk/search?hl=en%26amp;sa=...
How can we compile and run a soure code wrtiten on java or C/C++ from Another webpage or application software?
Actually we want to implement a simpler version of an Online Judge like some available online judging system ( Valladolid(UVA) / Sphere / TJU / ZJU / Saratov Online Judge etc. ) which can receive a source code and verify the output produced by that source code .
But we can not find any solutions about how to run a source code ( java / c / c++) that we received.
We are interested to use PHP as our tools. ( any opinion ? )
* * * We just need to implement a simpler Judge. Not as sophisticated as Others.
Addresses of some Available Online Judge :
UVA - old - http://acm.uva.es/p
new - http://icpcres.ecs.baylor.edu/onlinejudg...
Saratov - http://acm.sgu.ru/
Sphere - http://acm.sgu.ru/
How can we compile and run a soure code wrtiten on java or C/C++ from Another webpage or application software?
Having been involved in writing one a while back, writing judging software is not straightforward at all, and there are some security considerations that you should take VERY seriously. That said, once you've somehow (this is the hard part) verified that this source code is safe, all you need to do is to compile it to a temporary executable with the languages native compiler and run it, capturing its stdout for making purposes. It should not be too difficult?
EDIT:
ok, to update with a more specific answer. I'm not good with PHP, but lets pretend that you're using perl which I'm more familiar with. The syntax will be very similar. This will be a little pseudocodey, but close enough to real perl.
# So suppose you have all your request data in the hash CGI,
# things will be a little different in PHP but I'm sure you can figure
# it out.
use IO::File;
use POSIX qw(tmpnam);
my $sourceCode = $CGI{source};
# try new temporary filenames until we get one that didn't already exist
do { $name = tmpnam() }
until $fh = IO::File-%26gt;new($name, O_RDWR|O_CREAT|O_EXCL);
# install atexit-style handler so that when we exit or die,
# we automatically delete this temporary file
END { unlink($name) or die "Couldn't unlink $name : $!" }
# now go on to use the file ...
print $fh $sourceCode;
system("javac $name");
if ( `java $name.class` == $expectedOutput) {
print("Correct!\n");
}else{
print("Incorrect!\n");
}
So the steps are:
- Read the input file
- write it to a temp file
- invoke the correct compile (in this case javac)
- run the compile program and capture its output (in perl we can use ` ` to do that)
- check the captured output.
Did that answer your questions?
flowers uk
But we can not find any solutions about how to run a source code ( java / c / c++) that we received.
We are interested to use PHP as our tools. ( any opinion ? )
* * * We just need to implement a simpler Judge. Not as sophisticated as Others.
Addresses of some Available Online Judge :
UVA - old - http://acm.uva.es/p
new - http://icpcres.ecs.baylor.edu/onlinejudg...
Saratov - http://acm.sgu.ru/
Sphere - http://acm.sgu.ru/
How can we compile and run a soure code wrtiten on java or C/C++ from Another webpage or application software?
Having been involved in writing one a while back, writing judging software is not straightforward at all, and there are some security considerations that you should take VERY seriously. That said, once you've somehow (this is the hard part) verified that this source code is safe, all you need to do is to compile it to a temporary executable with the languages native compiler and run it, capturing its stdout for making purposes. It should not be too difficult?
EDIT:
ok, to update with a more specific answer. I'm not good with PHP, but lets pretend that you're using perl which I'm more familiar with. The syntax will be very similar. This will be a little pseudocodey, but close enough to real perl.
# So suppose you have all your request data in the hash CGI,
# things will be a little different in PHP but I'm sure you can figure
# it out.
use IO::File;
use POSIX qw(tmpnam);
my $sourceCode = $CGI{source};
# try new temporary filenames until we get one that didn't already exist
do { $name = tmpnam() }
until $fh = IO::File-%26gt;new($name, O_RDWR|O_CREAT|O_EXCL);
# install atexit-style handler so that when we exit or die,
# we automatically delete this temporary file
END { unlink($name) or die "Couldn't unlink $name : $!" }
# now go on to use the file ...
print $fh $sourceCode;
system("javac $name");
if ( `java $name.class` == $expectedOutput) {
print("Correct!\n");
}else{
print("Incorrect!\n");
}
So the steps are:
- Read the input file
- write it to a temp file
- invoke the correct compile (in this case javac)
- run the compile program and capture its output (in perl we can use ` ` to do that)
- check the captured output.
Did that answer your questions?
flowers uk
What is the program code in C programming that when i after i 10 numbers i could get the sum?
I really need the syntax or the code in C programming that after i enter ten (10) numbers, then i can get their sum. Please help me. Thank you so much. Godbless!!
What is the program code in C programming that when i after i 10 numbers i could get the sum?
#include%26lt;stdio.h%26gt;
#include%26lt;conio.h%26gt;
main()
{
clrscr();
int sum= 0,num;
printf("Enter 10 numbers");
for(i=0;i%26lt;=10;i++)
{
scanf("%d",%26amp;num);
sum = sum + num;
}
printf("Total Sum = %d",sum);
getch();
}
this program wat it does is it keeps adding the numbers as soon as you input them and so at the end when u tell it to output the value of sum u get the total sum of all the numbers that u entered.
What is the program code in C programming that when i after i 10 numbers i could get the sum?
#include%26lt;stdio.h%26gt;
#include%26lt;conio.h%26gt;
main()
{
clrscr();
int sum= 0,num;
printf("Enter 10 numbers");
for(i=0;i%26lt;=10;i++)
{
scanf("%d",%26amp;num);
sum = sum + num;
}
printf("Total Sum = %d",sum);
getch();
}
this program wat it does is it keeps adding the numbers as soon as you input them and so at the end when u tell it to output the value of sum u get the total sum of all the numbers that u entered.
Thursday, July 30, 2009
How can i convert C# code to vb.net code?
Outside of a line by line update - you do know that C#.NET libraries can be used by VB.NET right? Just something to think about..
How can i convert C# code to vb.net code?
Come on, all your DLLs can be refered by VB applications without convertion.
Reply:I actually use SharpDevelop if I find some snippet of code I'm too lazy to do it myself without a tool. SharpDevelop is a complete IDE, so it's not the most practical way but it's the most accurate way:
http://www.icsharpcode.com/OpenSource/SD...
I also use this one. There is also a desktop version to download:
http://www.kamalpatel.net/ConvertCSharp2...
Keep in mind, there may be some things in C# that just won't convert to VB .NET because there are still some things both languages have independently.
edit: Unless I'm misunderstanding the other answers: he's talking about converting snippets of code, guys.
How can i convert C# code to vb.net code?
Come on, all your DLLs can be refered by VB applications without convertion.
Reply:I actually use SharpDevelop if I find some snippet of code I'm too lazy to do it myself without a tool. SharpDevelop is a complete IDE, so it's not the most practical way but it's the most accurate way:
http://www.icsharpcode.com/OpenSource/SD...
I also use this one. There is also a desktop version to download:
http://www.kamalpatel.net/ConvertCSharp2...
Keep in mind, there may be some things in C# that just won't convert to VB .NET because there are still some things both languages have independently.
edit: Unless I'm misunderstanding the other answers: he's talking about converting snippets of code, guys.
Can someone explain this code in C programming language-char far *Vid_base=0xb8000000;*(Vid_bas...
These lines of code in C were used for displaying something.
Can u explain how it works or provide any link or book where i can find explaination.
Can someone explain this code in C programming language-char far *Vid_base=0xb8000000;*(Vid_bas...
?
Reply:This is a pointer to screen memory when you are in DOS mode (80 chars wide and 25 chars high). I don't think this will work in the windowed environment, only when you boot up something like Dos 6.22.
Advanced C, part 2 of 3
http://gd.tuwien.ac.at/languages/c/progr...
Can u explain how it works or provide any link or book where i can find explaination.
Can someone explain this code in C programming language-char far *Vid_base=0xb8000000;*(Vid_bas...
?
Reply:This is a pointer to screen memory when you are in DOS mode (80 chars wide and 25 chars high). I don't think this will work in the windowed environment, only when you boot up something like Dos 6.22.
Advanced C, part 2 of 3
http://gd.tuwien.ac.at/languages/c/progr...
Calculartor's programming Code in C++?
Will sombody provide Programming Code for Calculator in C++
Regards
Calculartor's programming Code in C++?
Most C/C++ textbooks have such code.
You can also find such code online: http://www.programmersheaven.com/downloa...
hamper
Regards
Calculartor's programming Code in C++?
Most C/C++ textbooks have such code.
You can also find such code online: http://www.programmersheaven.com/downloa...
hamper
I need a code in c++?
i need an code for a function in c++ using recursion?
this function i need to genrat this :
*
**
***
***
**
*
I need a code in c++?
Void PrintStars(Int Row)
{
Cout %26lt;%26lt;"\n";
For(i=0; i%26lt;Row; i++)
Count %26lt;%26lt;"*";
if Row %26lt; 3 then
PrintStars(++Row);
Cout %26lt;%26lt;"\n";
For(i=0; i%26lt;Row; i++)
Count %26lt;%26lt;"*";
}
Reply:salam
you had better to visit the site below and plan ur question there.
www.experts-exchange.com
Reply:Here is a set to calculate factorials using recursion. See if you can get it to fit what you need. ;)
#include %26lt;iostream%26gt;
2: using namespace std;
3:
4: int factorial(int n)
5: {
6: if (n %26gt; 1) {
7: return n * factorial(n - 1);
8: }
9: else {
10: return 1;
11: }
12: }
13:
14: int main()
15: {
16: int n;
17: int fact;
18:
19: cout %26lt;%26lt; "Enter a number: ";
20: cin %26gt;%26gt; n;
21:
22: fact = factorial(n);
23:
24: cout %26lt;%26lt; n %26lt;%26lt; "! = " %26lt;%26lt; fact %26lt;%26lt; endl;
25:
26: return 0;
27: }
Reply:#include%26lt;iostream.h%26gt;
#include%26lt;conio.h%26gt;
int main()
{
int i,j;
for(i=0;i%26lt;=5;i++){
for(j=0;j%26lt;=i;j++)
cout%26lt;%26lt;"**";
cout%26lt;%26lt;endl;}
for(i=0;i%26lt;=5;i++){
for(j=5;j%26gt;i;j--)
cout%26lt;%26lt;"**";
cout%26lt;%26lt;endl;}
getch();
}
Reply:function print(int row = 0){
if(row %26lt; 3)
for(int i=0;i%26lt;=row;i++) {
cout %26lt;%26lt; "*";
}
else
for(int i=5;i%26gt;=row;i--) {
cout %26lt;%26lt; "*";
}
if(row == 5)
return;
print(++row);
}
this function i need to genrat this :
*
**
***
***
**
*
I need a code in c++?
Void PrintStars(Int Row)
{
Cout %26lt;%26lt;"\n";
For(i=0; i%26lt;Row; i++)
Count %26lt;%26lt;"*";
if Row %26lt; 3 then
PrintStars(++Row);
Cout %26lt;%26lt;"\n";
For(i=0; i%26lt;Row; i++)
Count %26lt;%26lt;"*";
}
Reply:salam
you had better to visit the site below and plan ur question there.
www.experts-exchange.com
Reply:Here is a set to calculate factorials using recursion. See if you can get it to fit what you need. ;)
#include %26lt;iostream%26gt;
2: using namespace std;
3:
4: int factorial(int n)
5: {
6: if (n %26gt; 1) {
7: return n * factorial(n - 1);
8: }
9: else {
10: return 1;
11: }
12: }
13:
14: int main()
15: {
16: int n;
17: int fact;
18:
19: cout %26lt;%26lt; "Enter a number: ";
20: cin %26gt;%26gt; n;
21:
22: fact = factorial(n);
23:
24: cout %26lt;%26lt; n %26lt;%26lt; "! = " %26lt;%26lt; fact %26lt;%26lt; endl;
25:
26: return 0;
27: }
Reply:#include%26lt;iostream.h%26gt;
#include%26lt;conio.h%26gt;
int main()
{
int i,j;
for(i=0;i%26lt;=5;i++){
for(j=0;j%26lt;=i;j++)
cout%26lt;%26lt;"**";
cout%26lt;%26lt;endl;}
for(i=0;i%26lt;=5;i++){
for(j=5;j%26gt;i;j--)
cout%26lt;%26lt;"**";
cout%26lt;%26lt;endl;}
getch();
}
Reply:function print(int row = 0){
if(row %26lt; 3)
for(int i=0;i%26lt;=row;i++) {
cout %26lt;%26lt; "*";
}
else
for(int i=5;i%26gt;=row;i--) {
cout %26lt;%26lt; "*";
}
if(row == 5)
return;
print(++row);
}
What is the code in C programming that after i 10 numbers i could get their sum?
I really need the syntax or the code in C programming that after i enter ten (10) numbers, then i can get their sum. Please help me. Thank you so much. Godbless!!
What is the code in C programming that after i 10 numbers i could get their sum?
#include%26lt;stdio.h%26gt;
#include%26lt;conio.h%26gt;
main()
{
clrscr();
int sum=0, num,avg;
printf("Enter 10 numbers");
for(i=0;i%26lt;=10;i++)
{
scanf("%d",%26amp;num);
sum=sum+num;
}
avg=sum/10;
printf("Sum = %d\nAverage =%d\n",sum,avg);
getch();
}
Reply:Has anyone seen a question more lame??Please let me know if you have...
Reply://heres what I would do:
int a^=a;for(int p=a;p%26lt;012;++p)a+=n[p];
//where n[] is your array of 10 numbers, and a is the total
What is the code in C programming that after i 10 numbers i could get their sum?
#include%26lt;stdio.h%26gt;
#include%26lt;conio.h%26gt;
main()
{
clrscr();
int sum=0, num,avg;
printf("Enter 10 numbers");
for(i=0;i%26lt;=10;i++)
{
scanf("%d",%26amp;num);
sum=sum+num;
}
avg=sum/10;
printf("Sum = %d\nAverage =%d\n",sum,avg);
getch();
}
Reply:Has anyone seen a question more lame??Please let me know if you have...
Reply://heres what I would do:
int a^=a;for(int p=a;p%26lt;012;++p)a+=n[p];
//where n[] is your array of 10 numbers, and a is the total
I need urgent code for c++ program of library management......?
plz can anyone give me the code for library management in c++. plz help me..i need ur help !!!
I need urgent code for c++ program of library management......?
C++ does not have such functions. They are provided by the operating system.
unix: dlopen()
windows: LoadLibrary, GetProcAddress
search the documentation for details, and next time write more information to get better answers.
I need urgent code for c++ program of library management......?
C++ does not have such functions. They are provided by the operating system.
unix: dlopen()
windows: LoadLibrary, GetProcAddress
search the documentation for details, and next time write more information to get better answers.
I want to implement hamming code(n,k) in c/c++,,can any 1 help me..?
i hav to implement hamming code using c/c++ ,,so plz anyone knows how to do it? or algorithm for it,,then post me...
if the whole prog isnt there then plz send me atleast logic fro that so i can hav a idea for implmenting that
I want to implement hamming code(n,k) in c/c++,,can any 1 help me..?
"hamming code" in Wikopedia has an algorithm
bloom
if the whole prog isnt there then plz send me atleast logic fro that so i can hav a idea for implmenting that
I want to implement hamming code(n,k) in c/c++,,can any 1 help me..?
"hamming code" in Wikopedia has an algorithm
bloom
What is the code in C programming that after i enter 10 numbers i can sort get their sum and average?
Please help me solve this problem in C programming. I need the code for a program that when i enter ten numbers, then i could get their sum and average.Thank you so much.
What is the code in C programming that after i enter 10 numbers i can sort get their sum and average?
C
Reply:all you need is an array to store your numbers
then have a loop to do your calculations
Reply:#include%26lt;stdio.h%26gt;
#include%26lt;conio.h%26gt;
main()
{
clrscr();
int sum=0, num,avg;
printf("Enter 10 numbers");
for(i=0;i%26lt;=10;i++)
{
scanf("%d",%26amp;num);
sum=sum+num;
}
avg=sum/10;
printf("Sum = %d\nAverage =%d\n",sum,avg);
getch();
}
What is the code in C programming that after i enter 10 numbers i can sort get their sum and average?
C
Reply:all you need is an array to store your numbers
then have a loop to do your calculations
Reply:#include%26lt;stdio.h%26gt;
#include%26lt;conio.h%26gt;
main()
{
clrscr();
int sum=0, num,avg;
printf("Enter 10 numbers");
for(i=0;i%26lt;=10;i++)
{
scanf("%d",%26amp;num);
sum=sum+num;
}
avg=sum/10;
printf("Sum = %d\nAverage =%d\n",sum,avg);
getch();
}
In c, how to write a code to sort one field based on another?
for example, i have two fields id and value.....
id value
1 13
2 50
3 12
4 19
I shoud get like this
id value
2 13
4 50
1 12
3 19
I mean i need to rearrange id based on value(in ascending order).
I have an array for each id and value..... help me to code in c....
In c, how to write a code to sort one field based on another?
Use the Bubble sort method.
http://www.metalshell.com/view/source/10...
If you are writing a code, people will might you in case of any problem.
Don't ask for code here (there are many sites in the Internet where free codes are available). The reason is, you end up not learning it.
Reply:Use the qsort() function http://www.cppreference.com/stdother/qso...
Reply:Hema this link might help you
http://www.google.co.uk/search?hl=en%26amp;q=f...
Reply:For homework help there are better websites like http://getafreelnacer.com/
id value
1 13
2 50
3 12
4 19
I shoud get like this
id value
2 13
4 50
1 12
3 19
I mean i need to rearrange id based on value(in ascending order).
I have an array for each id and value..... help me to code in c....
In c, how to write a code to sort one field based on another?
Use the Bubble sort method.
http://www.metalshell.com/view/source/10...
If you are writing a code, people will might you in case of any problem.
Don't ask for code here (there are many sites in the Internet where free codes are available). The reason is, you end up not learning it.
Reply:Use the qsort() function http://www.cppreference.com/stdother/qso...
Reply:Hema this link might help you
http://www.google.co.uk/search?hl=en%26amp;q=f...
Reply:For homework help there are better websites like http://getafreelnacer.com/
HI I have old code that was written in 16-bit C language in 1982 we want to comvert it to C#. IS there a way?
HI
I am a developer and we have some old code that was written in C around the year 1982. We would like to convert it into 32-bit code in C#. Is there an easy way of doing that. I mean some software that can do the task.
Any help will be highlt appreciated.
Rgds
Vaibhav
HI I have old code that was written in 16-bit C language in 1982 we want to comvert it to C#. IS there a way?
It would probably be easier to convert it to managed C++ if that's an option. You could also use a C to C++ converter (like http://www.scriptol.org/ctocpp.php) and then use .NET's automatic C++ to C# conversion tool.
Reply:Have you tried using the nintendo 32 bit?
I am a developer and we have some old code that was written in C around the year 1982. We would like to convert it into 32-bit code in C#. Is there an easy way of doing that. I mean some software that can do the task.
Any help will be highlt appreciated.
Rgds
Vaibhav
HI I have old code that was written in 16-bit C language in 1982 we want to comvert it to C#. IS there a way?
It would probably be easier to convert it to managed C++ if that's an option. You could also use a C to C++ converter (like http://www.scriptol.org/ctocpp.php) and then use .NET's automatic C++ to C# conversion tool.
Reply:Have you tried using the nintendo 32 bit?
How can i convert MATLAB code to other code(like C++, basic,FORTRAN,...)?
i want to write my program in MATLAB(m-file) and run it in a computer without MATLAB software. so i need a way to tranlate m-file to other code like c,c++,basic,fortran,... by the way, my code contain some functions.
How can i convert MATLAB code to other code(like C++, basic,FORTRAN,...)?
Mathworks is selling its translator. Another alternative is MATCOM, which is a is freeware
translator of MATLAB to C++. It seems to work pretty well, but can be confused by feval() and gives up on eval().
Sorry, links i've sent you are all dead... Try to find it yourself.
Reply:Maple.
You can derive it symbolically in maple, then translate it to matlab, fortran, c or other language options.
You might seriously consider learning python and using the open source symbolic solver libraries, graphic libraries, and numeric libraries.
Reply:1. Rewrite the application in desired langauge
2. Purchase a tool that converts it
dogwood
How can i convert MATLAB code to other code(like C++, basic,FORTRAN,...)?
Mathworks is selling its translator. Another alternative is MATCOM, which is a is freeware
translator of MATLAB to C++. It seems to work pretty well, but can be confused by feval() and gives up on eval().
Sorry, links i've sent you are all dead... Try to find it yourself.
Reply:Maple.
You can derive it symbolically in maple, then translate it to matlab, fortran, c or other language options.
You might seriously consider learning python and using the open source symbolic solver libraries, graphic libraries, and numeric libraries.
Reply:1. Rewrite the application in desired langauge
2. Purchase a tool that converts it
dogwood
How I Can write code in C++ that will declare, initialize, and fill in an array of objects of type int. After
How I Can write code in C++ that will declare, initialize, and fill in an array of objects of type int. After your code executes, the array should look as follows.
0 2 4 6 8 1012141618
How I Can write code in C++ that will declare, initialize, and fill in an array of objects of type int. After
check out http://www.pscode.com for great sample codes.
Reply:Im also studying the C language!Good luck to us!
Reply:int iArray[] = new int[]{0,2 ,4, 6 ,8 ,10,12,14,16,18}
int i = 0;
for (i = 0; i %26lt; 10; i++)
cout%26lt;%26lt;i;
Reply:int myArray[10];
for (int x = 0; x%26lt; 10; x++) {
myArray[x] = 2*x;
}
0 2 4 6 8 1012141618
How I Can write code in C++ that will declare, initialize, and fill in an array of objects of type int. After
check out http://www.pscode.com for great sample codes.
Reply:Im also studying the C language!Good luck to us!
Reply:int iArray[] = new int[]{0,2 ,4, 6 ,8 ,10,12,14,16,18}
int i = 0;
for (i = 0; i %26lt; 10; i++)
cout%26lt;%26lt;i;
Reply:int myArray[10];
for (int x = 0; x%26lt; 10; x++) {
myArray[x] = 2*x;
}
C++ exit code..?
Hi, can some1 explains to me what this return codes mean in C++? return 0, return 1, return -1 Thanks
C++ exit code..?
The value returned may have an intrinsic meaning depending on where it is placed.
If the value is in the "main" subroutine, returning zero is a good thing. It says that the program exited normally. Returning anything else generally signifies an error.
As far as any other routine, 0 is false and anything else is true. (Although, you should use explicit constants if you're looking for a Boolean answer.)
HTH
Reply:Returning values of a specific (int) function. The meaning (if is your function and no predefined function in some lib) is yours to choose...
Reply:it makes the function return a value...this is probably best shown by an example
int function
{
cout %26lt;%26lt; "I like tacos and rockstars";
return 17;
}
now the value of int function (yes, the FUNCTIONs value)
has a value of 17 when that function finishes all lines of code.
Reply:The return keyword allows you to specify what variable or value will be passed back to the calling function when the function it is in is terminated. It can be used to determine a runtime status for a function or to pass a pointer to a data object / structure so that multiple results can be retrieved.
C++ exit code..?
The value returned may have an intrinsic meaning depending on where it is placed.
If the value is in the "main" subroutine, returning zero is a good thing. It says that the program exited normally. Returning anything else generally signifies an error.
As far as any other routine, 0 is false and anything else is true. (Although, you should use explicit constants if you're looking for a Boolean answer.)
HTH
Reply:Returning values of a specific (int) function. The meaning (if is your function and no predefined function in some lib) is yours to choose...
Reply:it makes the function return a value...this is probably best shown by an example
int function
{
cout %26lt;%26lt; "I like tacos and rockstars";
return 17;
}
now the value of int function (yes, the FUNCTIONs value)
has a value of 17 when that function finishes all lines of code.
Reply:The return keyword allows you to specify what variable or value will be passed back to the calling function when the function it is in is terminated. It can be used to determine a runtime status for a function or to pass a pointer to a data object / structure so that multiple results can be retrieved.
Subscribe to:
Posts (Atom)