Tuesday, July 14, 2009

C code problem?

#include%26lt;stdio.h%26gt;


int calsum(int x,int y, int z);


main()


{


int a,b,c, sum;


printf("\n Enter any three numbers");


scanf("%d %d %d",%26amp;a, %26amp;b, %26amp;c);


sum = calsum(a,b,c);


printf("\nSum=%d",sum);


}


int calsum(int x,int y,int z)


int x,y,z,;





{


int d;


d=x+y+z;


return (d);


}


error messages is


function should return a value in function main()


declaration syntax error


deceleration terminated incorrectly


Plz tell me where I am wrong

C code problem?
#include%26lt;stdio.h%26gt;


int calsum(int x,int y, int z); **** write int calsum(int, int, int);


main()


{


int a,b,c, sum;


printf("\n Enter any three numbers");


scanf("%d %d %d",%26amp;a, %26amp;b, %26amp;c);


sum = calsum(a,b,c);


printf("\nSum=%d",sum);


}


int calsum(int x,int y,int z)


int x,y,z,; ****remove this





{


int d;


d=x+y+z;


return (d); ***use return d;


}





Please try then tell me if u still encounter error
Reply:main() should be void main()








replace the main() by void main()
Reply:return 0;





in main
Reply:The main method returns an integer value by default. Since in your code, no value is returned by the main(), the error occurs.





You may either choose to define main as





void main()


{


// your code goes here


}





or,





main()


{


// your code





return 0;


}
Reply:type return 0; in the last line in the main program. surely this will solve this problem

daffodil

Is that a program that will automatically generate a header file from my c programming source code(not C++).?

I am programming a c language linked list stack in a program called Eclipse. I have the source code in stack.c. I am looking for a program that will scan my stack.c source code and generate a stack.h header file automatically.





Please let me know if there is anything like that out there and a quick explanation of how to use. it.





Thank You

Is that a program that will automatically generate a header file from my c programming source code(not C++).?
no its program that takes few codes from header files and use it


C code question regarding malloc() and free().....?

file ----%26gt;input.h (contents of input.h)


float * datain();


file ----%26gt;input.c(contents of input.c)


#include %26lt;malloc.h%26gt;


//.....other includes


float *datain()


{


float *data;


//routine to get data........


return(data);


free (data) ///????????


}





assuming I have a main.c function in the same project which calls datain()...is it legal operation to free the pointer after returning the pointer to the main function? even though I need to do some thing to the returned data?





file----------%26gt;main.c





#include %26lt;malloc.h%26gt; ....//other includes


#include "input.h"





void main ()


{


float *getdata;


getdata = datain();





// .....do something to get data;





}








Thanks in advance

C code question regarding malloc() and free().....?
statements after return statement are not executed.


so basically, your function does not execute the line


%26gt; free(data)





instead of that, you could define a structure and two functions,





typedef struct {


float * data;


int valid;


} datastruct;





datastruct get_data(){


float *tmp;


// malloc(tmp)





// copy data to memory pointed by tmp





datastruct result = {tmp, 1};


}





float free_data(datastruct *pdata){


if (pdata -%26gt; valid){


pdata -%26gt; valid = 0;


free (pdata -%26gt; data);


}


}





==================





and inside your main function:





void main(){


datastruct data;


data = get_data();





// do smth to data





free_data(%26amp;data);


}
Reply:you're right, the struct is not really needed. Report It

Reply:Actually in C different memory space will be alloted for the functions so whenever u pass a data the value will be passed but when it is a pointer it only passes the address of the pointer so if u pass a pointer from one function to another the address of the pointer will be passed.





If u want to free a pointer the u need to pass the data value instead of using address of the pointer


ie instead of return(data); use return(*data); It passes the data value so when u free the location u dont have any problem





If u free the pointer only the pointer will be freed ie if u free data then it will be deleted (the location having the address of original data )as u have already passed the address if u free there is no problem .if u free first the original address of data will be lost thus the data becomes inaccessible .








I think i have atleast solved some of your problems
Reply:I really didn't use C before ... but i know the pointers concept.





I think there's no problem if u make the pointer "data" free after returning the data


even if u need to do things to the returned data in the main.





----


*u've pointer "data" in dataIn() and pointer "getData" in the main,


*what is really done here is that u recieved some DATA


*the DATA now is in the memory with address "150" for example


*u put the address "150" in the pointer "data"


*u returned the pointer value to the pointer "getData"


*then "getData" now contains the address "150"





i don't know the function "free" but,





when u free(data):





-if that means u make the pointer itself free and not points any DATA, so u still have the pointer "getData" points to the same data.





-if it means u'll delete the actual DATA pointed by the pointer "data", then that's wrong





but it seems like the 1st meaning is right


----------------


another thing :


as i said b4, i didn't use C before ... but in Java, the statements after "return" aren't reachable as the function ends at the word "return", i don't know if it's the same thing in C or not
Reply:[747] cmalloc: cat main1.c


#include %26lt;stdio.h%26gt;


#include %26lt;stdlib.h%26gt;





float *dataIn( void )


{


float *dataPtr = malloc( sizeof(float) );





*dataPtr = 1.2345;


return dataPtr;


}





int main( int argc, char* argv[] )


{


float *myDataPtr = dataIn();





printf( "myDataPtr: %p\n", myDataPtr );


printf( "*myDataPtr: %f\n", *myDataPtr );





free( myDataPtr );


return 0;


}


[748] cmalloc: gcc -Wall main1.c


[749] cmalloc:


[749] cmalloc: ./a.out


myDataPtr: 0x3000f0


*myDataPtr: 1.234500








The dataIn() function allocates the memory, fills it in, and returns a pointer to the data. The main() function gets a pointer to the data from the dataIn() function. The ownership of the allocated memory passes from the dataIn() function to main(). The main() does whatever it wants with the data and then frees the memory.





You must NOT free the memory until all the program is completely done using the data stored within the memory.


C# code help?

Hello. I am trying to get a program to insert the date at where current text is being typed (not explained very well, I mean the little line when you type name is on the tip of my tongue...). At first I tried to get it to appear using the following code





[code]


rchTextCode = rchTextCode.txt + DateTime.Today;


[/code]





But it only added it at the end of the text





I am sure I am doing something really obviously wrong, any help?

C# code help?
I work with VB but looking at MSDN it seems similar....so try...





rchTextCode.SelectedText = rchTextCode.SelectedText + DateTime.Today;
Reply:use the selectionstart property to determine the


location of the cursor/caret.





richTextBox1.Text=


richTextBox1.Text.Insert


(richTextBox1.SelectionStart , "hello world");


Please suggest a tool for debugging memory leak in C++ source code?

Hi... we are providing software support for one of the famous retailers in U.S. The code has been written in C++. Our field test customers feel that the application software is very slow.


Before we deliver the software to our clients, we are in a urge to improve the performance of the application. Some of our software engineers suspect that the memory dirty pages are too high in the application. They feel that the code have lot of memory leaks. Are there ways to improve the performance of the software?? Is there any tool that finds us the memory leaks in the code? Please suggest?

Please suggest a tool for debugging memory leak in C++ source code?
For MSVC, we sometimes use BoundsChecker--decent tool. The wiki page on BoundsChecker will give you other vendors.





http://en.wikipedia.org/wiki/BoundsCheck...
Reply:Hi, typically, a memory leak occurs because dynamically allocated memory has become unreachable. You can prevent memory leaks by watching for some common problems. Collection classes, such as hash tables and vectors, are common places to find the cause of a memory leak. This is particularly true if the class has been declared static and exists for the life of the application. . The prevalence of memory leak bugs has led to the development of a number of debugging tools to detect unreachable memory. Coverity Prevent is one of the tool that you can use for fixing these kinds of bugs. Coverity Prevent is also used by the Department of Homeland security to scan many open source projects. You can get more info at http://www.Coverity.com
Reply:Use purify.

hyacinth

How to write DllImport kernel32 in C++.net unmanaged code?

Can someone tell me syntax for importing SetEnvironmentVariable from kernel32.dll in C++ unmanaged code.

How to write DllImport kernel32 in C++.net unmanaged code?
check out http://www.pscode.com - site with good examples
Reply:Wow...I have no clue what you're talking about. LOL.


I'm searching for a c++ source code that does Quine McCluskey reduction?

Hello, I'm Sudesh. I hope you guys can do me a favour. I'm searching for a


C++ source code that does Quine McCluskey reduction. I've been searching the


net for it but can't seem to find it. I hope there is someone here who can


help.

I'm searching for a c++ source code that does Quine McCluskey reduction?
There may not exist a C++ solution on the web, but I Googled "Quine McCluskey reduction" and got quite a few results. I believe at least a few could be helpful for your purposes... In fact, I found one result in C that looked very promising -which I'll provide below...
Reply:You're quite welcome... Report It

Reply:http://en.wikipedia.org/wiki/Quine-McClu...





Coding it based on this description should be a reasonably easy task for a C++ programmer such as yourself.





Rawlyn.


Dutch national flag problem c# source code?

i am trying to find the source code for the dutch national flag problem (2 colour) in C# its really been doing my head in. actually the varition i am working on is sorting an array so that negative numbers go first. any help muchy aprciated!! (alberttietz@yahool.com.au)

Dutch national flag problem c# source code?
As for the flag, are you drawing? Isn't it only like three boxes? Just look for drawing tutorials on the net and extend what they teach to suit your problem.





For the array sorting - if you are sorting with lowest numbers first, then negative numbers will automatically come first in the list, as they are numerically lower than the positive numbers.





Rawlyn.


I have a code in VB but i want it in C#?

I have a code in VB but i want it in C#


the code is:


' Prototype UI


Public Declare Function LoadKeyboardLayout Lib


"USER32" Alias "LoadKeyboardLayoutA" (ByVal pwszKLID


As String, ByVal Flags As Long) As Long





Public Const Switch2En = "00000409"


Public Const Switch2Fa2000 = "00000429"





Public Sub Switch(ByVal strSwitch As String)


' Prototype UI


strSwitch = UCase(strSwitch)


If strSwitch = "EN" Then


LoadKeyboardLayout(Switch2En, 1)


ElseIf strSwitch = "FA" Then


LoadKeyboardLayout(Switch2Fa2000, 1)


End If


End Sub

I have a code in VB but i want it in C#?
try this


http://www.carlosag.net/Tools/CodeTransl...





hope it works...

poppy

Hi! my question is regarding to the conversion of C-language code to Assembly Language code?

i heard from my teacher that u can easily convert C-laguage code into Assembly language code (.asm file) by writting just one command in dos mode i.e c:\%26gt;tc -b *.cpp this command will automatically generate .asm file with some other files i tried it but it didn't work so vat will be the way to decode c-language file into .asm file?

Hi! my question is regarding to the conversion of C-language code to Assembly Language code?
It depends on the system you are using. All C compilers create assembly code which is then passed to an assembler. There is usually an option to create the assembly code but not assemble it.





If you give me an idea whuch OS?compiler you are using I can probably tell you exactly how to do it.





For example gcc -S will only produce assembler output
Reply:I assume you're using Turbo C. Then try running tc -S *cpp instead. According to the manual ( http://bdn.borland.com/article/20997 ) this should produce asm code.


Extract or View C++ Source code from an exe file?

Is there any way I can extract or at least the C++ source file of an exe file. Im really in need of help Iv only got the exe file and iv lost the source code. Please Some one Help.

Extract or View C++ Source code from an exe file?
A simple answer would be, No. You cannot extract the c++ source files (.cpp) from an .exe.





You can reverse engineer the binary file. You can always get the Assembly Source code (hopefully). Cause an EXE is a binary compilation. So you cannot get the .cpp files only the assembled code which is ASSEMBLY.





You could either DEBUG the exe and see the application run in Assembly, or use some kind of reverse engineering tool like DA.PRO





Take a look at Assuming its .NET:


http://www.netdecompiler.com/index.html


http://www.junglecreatures.com





It is illegal to get the source code of an EXE. Cause if the programmer wants the user to see the source code, he could of included it. Unless your learning how to crack software, then your doing something which isn't good.
Reply:No. Once a high-level language program is compiled into the assembly code, the information of the original source is lost. You cannot get back to the source code.





There is no one-to-one relationship between a high-level language statement and an assembly instruction. One statement is normally compiled to more than one instructions. Then the compiler attempt to optimize the code by removing redundant code, or replacing a code segment with better instructions.





So, why you cannot reverse engineering back the source? First, you do not know where the boundaries of two high-level languages are. Second, after optimization, you don't even have instructions for a complete statement anymore.
Reply:no.


C++ code to replace words in a document, keep getting run error?

string replace


string aword;


char c;





string in_file_name = "Slim Shady.txt";





ifstream fin;





fin.open(in_file_name.c_str());





if(!fin)


{


cout %26lt;%26lt; endl


%26lt;%26lt; "could not open " %26lt;%26lt; in_file_name %26lt;%26lt; flush;





cin.get();





return -1; //Can't carry on if the file is not open


}





string out_name = "";





out_name = out_name + "clean_" + in_file_name;








ofstream fout;





fout.open(out_name.c_str());





if(!fout)


{


cout %26lt;%26lt; endl


%26lt;%26lt; "could not open " %26lt;%26lt; out_name %26lt;%26lt; flush;





cin.get();





return -1; //Can't carry on if the file is not open


}








//Ask user for foul_word


if (!fout)


{





cout%26lt;%26lt; " input foul_word"%26lt;%26lt;endl;





cin%26gt;%26gt; "foul_word"%26gt;%26gt;endl;





cin.get();





return -1;











//make expletive using foul_word





//change foul_word to upper case








string expletive= makeexpletive(foulword);





foulword toupper(foulword);








fin %26gt;%26gt; aword;





while(!fin.fail())


{





string temp= toupper aword


int where = temp.find (0,foulword);





if(where!=-1)


{


}


aword.replace





string temp= replace( foulword, string temp(), s2 ); cout %26lt;%26lt; s %26lt;%26lt; endl


//create temp string that is tuupper version of aword





//if foul_word is in temp then replace foul_word with expletive in aword





aword.replace( where,foulword.length(),expletive);








fout %26lt;%26lt; aword;





fin.get( c );





while(isspace(c))


{


c = toupper(c);





fout %26lt;%26lt; c;





//in case the end of file is a space


if(fin.fail())


{


break;


}





fin.get(c);


}





aword = "";





aword = aword + c;





string next_word;





fin %26gt;%26gt; next_word;





aword = aword + next_word;








}


//cin.get();





fin.close();


fout.close();





return 0;





}











string toupper(string s)


{


string temp = "";


for(int i=0; i%26lt;s.size(); i++)


{


char c = toupper(s[i]);


temp = temp + c;


}


return s;


}





string makeexpletive(string s)


{





char face;


string temp ="";





srand(time(0));








for(int i = 0; i %26lt; s.length(); i++)


{





face = rand() % 5 + 1;





switch(face)


{


case 1 : temp = temp + '$'; break;


case 2 : temp = temp + '%26amp;'; break;


case 3 : temp = temp + '?'; break;


case 4 : temp = temp + '*'; break;


case 5 : temp = temp + '@'; break;





}


}





return temp;


}

C++ code to replace words in a document, keep getting run error?
Telling us what Run Error you're getting might help. Besides the fact that you don't even say what compiler you're using, few people here want to take the time to cut-and-paste all your code into our compiler, then work through getting it to compile and start running to find out what it MIGHT be.





Sorry that's not directly helpful, but it's good advice.
Reply:hey dude, u missing some semicolons maybe. at least i spot one.





string replace //u forgot to put a semi colon here





and did u write


#include %26lt;iostream%26gt;


#include %26lt;iomanip%26gt;


#include %26lt;fstream%26gt;


#include %26lt;string%26gt;


etc etc.??
Reply:(what%26gt; the}


Run...hell=you


switch....


talking@@[dd}


((0))


about.


Please help me convert this C program to JAVA soure code(program):?

the output of this given program is:





1


1 1


1 2 1


1 3 3 1


1 4 6 4 1


15 10 10 5 1


1 6 15 20 15 6 1


1 7 21 35 35 21 7 1


1 8 28 56 70 56 28 8 1


1 9 36 84 126 126 84 36 9 1





and here is the C source code(program)of the output above! please help me convert this C source code to JAVA source code(program) completely, with the same output as from the above.





#include%26lt;stdio.h%26gt;


#include%26lt;conio.h%26gt;





long ncr(int n,int r){ /*function to calculate nCr*/


int i=1;


long ncr=1;





while (n%26gt;r){


ncr=ncr*n/i;


n=n-1;


i=i+1;


}


return ncr;


}


void main()


{


clrscr();


int n,i,j,k;


printf("How many rows?");scanf("%d",%26amp;n);





for(i=1;i%26lt;=n;i++){


for (k=1;k%26lt;=n-i;k++) printf(" ");


for(j=0;j%26lt;=i-1;j++){ /* print terms */


printf("%d ",ncr(i-1,j)); /* of one */


} /* row */


printf("\n\n"); /* Goto next row */


}





getch();


}

Please help me convert this C program to JAVA soure code(program):?
// u can not use n like u did, even in C or C++, i corrected it by using x instead


private long ncr(int n, int r)


{


int i=1; int x=n;


long ncr=1;


while (x%26gt;r)


{


ncr=ncr*x/i;


x=x-1;


i=i+1;


}


return ncr;


}





public static void main(String arg[ ])


{


int n,i,j,k;


System.Out.Println("How many rows?"); // i forgot if the O and P are caps or not


int n=System.in.readline();





for (i=1; i %26lt;= n; i++)


for (k=1;k%26lt;=n-i;k++) System.out.println();


for(j=0;j%26lt;=i-1;j++){ /* print terms */


System.out.println("%d ",ncr(i-1,j)); /* of one */


} /* row */


System.out.print("\n\n"); /* Goto next row */


}


}

cosmos

How to write code in C program for converting Celsius to Fahrenheit?

Does any one knows the c program code to convert celsius to Fahrenheit? Can you please type in the code as the answer. Thanks in advance.

How to write code in C program for converting Celsius to Fahrenheit?
#include%26lt;stdio.h%26gt;





float C2F(float c) {return (c*1.8)+32;}





main() {


float celsius, fanrenheit;





// 30C = 86F, check


celsius = 30;


fanrenheit = C2F(celsius);


printf("%2f",fanrenheit);


}
Reply:double convert(double celsius) {


double fahrenheit;


fahrenheit = celsius + 32 * 5/9;


return fahrenheit;


}
Reply:This is a stock standard intro program.





If you don't know how to do it (and haven't the internet skills to search for it outside of here) you need to tell your teacher because either they are a bad teacher or you are doing the wrong course.


///


Yahoo pool aimer c++ programming code?

is there any website or somethin on which i can find the code(source code) for yahoo pool aimer so i just copy it and paste it in to my C++ and then run it and get an yahoo pool aimer for me ????? or if there is any way i can too design one for my self easily (if yes explain how)

Yahoo pool aimer c++ programming code?
if u get answer,tell me too...thnx


I want c source code to solve linear programming ploblems by simplex method .can u give me source code?

please send me c source code of LPP

I want c source code to solve linear programming ploblems by simplex method .can u give me source code?
The GNU Linear Programming Kit is the most advanced and easiest free package to use for LPP. It comes with all the C source code, too. It's hard to answer your question with source because there are many representations of the matrices used. Check out the GNU source and perhaps you can learn a bit from that.


How to I make a tool for Modifying C/C++ Source code to remove a global variable of interest ?

I need to remove specified global variable from C/C++ souce code. For this i need to make a tool. I dont know much about C so I am looking towards making the tool using java. Could someone help me out with how i can do this. I know that once the specified variable is removed it will destroy the functionality of the original source code but the functionality is of no interest to me. I just need all occurances of the specified variable to be ripped and thrown out from the source code while keeping as much of the original code intact as possible. NOTE : after this the source code must still be compilable although the functionality will not work.

How to I make a tool for Modifying C/C++ Source code to remove a global variable of interest ?
Won't work in most cases. You'll have to remove entire lines of code to make this correct. if(x == 4) { printf("%d\n", x); will break if you remove the variable x. This will break the functionality and the code.





If you are going to replace it with another variable, then it will still work, but if not, I don't see why you are wanting to do this.
Reply:Many programs (Visual Studio, Notepad, Dev-C++) have a feature to find and replace text in a document/project. This can usually be found by going to Edit -%26gt; Find and Replace, where you can then simply enter the variable you wish to replace and leave the "Replace with" line blank to remove all occurrences of that variable.

online florists

How i can run c++(source code ) or project in c++ software?

how i can run c++(source code ) or project in c++ software describe the procedure to run project in c++ reply soon

How i can run c++(source code ) or project in c++ software?
If you have visual basic for C++ then let me know and i can guide you through it. Else download it, its free...





http://www.microsoft.com/downloads/detai...
Reply:all i no 'bout c++ is that its used in making games with gamemaker when you wanna make a 3-D one


C++ source code needed!!?

ok i wanna make a program (i dun care if its windowed or not)





that lists a string then moves it slowly accorss the screen then like a sideways scroll





i thought about something like





cout%26lt;%26lt;" stuff here";


system ("cls");


cout%26lt;%26lt;" stuff here";





and keep repeating that





but i soon realized it'd do it all realyl fast


so i added a small amout of code after


#include %26lt;iostream%26gt;


so it understod


wait (#)


# bieng amount of time in seconds to wait


so i added that in so it'd go slower





another problem


it'd take a relaly long time to type out all that is needed


so it'd be a realyl long lengthy proccess





and im sure that there is another better way





but im not advance enougb in C++ to figure it out





someone plz help me out here





p.s. making string into a variable?


using VARIABLE++ to increase string maybe?





i duno just random thoughts O.o

C++ source code needed!!?
Ok... It looks like U r doing it in windows.... Let me know about the compiler U r using....mail me at raghuraj19@gmail.com..... I'll mail back the code in C language but using graphics which is a lot simpler.... U can then not only scroll horizontally... But also vertically... Tell me the compiler U r using....


C++ sorce code for user input matrix size & values during runtime and rotate 90 degrees clockwise?

I'm having problems rotating 90 degrees clockwise for a matrix with user inputing size %26amp; values during runtime and rotation is performed in function. How to pass matrix to function %26amp; use pointers for this problem?





Here's the question.





Write %26amp; rtest the function that rotate 90 degrees clockwise a two-dimensional square array of ints. For example, it would transform the array





11 22 33


44 55 66


77 88 99





to





77 44 11


88 55 22


99 66 33





The program should use dynamic memory allocation to allocate memory for the 2D array after getting the size of the square array.





It's hard to rotate when having the user giving array size and rotate based on the size.





Please insert the C++ source code for this question.





All helps are appreciated.TQ very much.

C++ sorce code for user input matrix size %26amp; values during runtime and rotate 90 degrees clockwise?
To use pointer with 2D matrix it is better to use pointer to a pointer. It can be used like usual 2D array.


Code in main should be something like below


//input dimension from user, m by n matrix


int** matrix;


matrix=new int*[m];


for( i=0;i%26lt;m;i++)


matrix[i]=new int[n];


// now input matrix from user in usual way.





now you can use this pointer to pointer as usual 2D array, when calling function just pass pointer to pointer as argument.


I have said you how to raotate 2D array in your previous question. I'm just repeating procedures, not the code.


First transpose the matrix and then reflect it wrt horizontal axis. I think this will work.
Reply:Run it u can get some idea ...





#include%26lt;stdio.h%26gt;


#include%26lt;conio.h%26gt;





#include%26lt;stdlib.h%26gt;





# define ROW 4


# define COL 4





void rotate_90(int**,int,int);


void print_matrix(int* m , int r, int c );











int main()


{


int * matrix ;


matrix= (int*)malloc(COL*ROW*sizeof(int));


int count=0;





for(int i=0;i%26lt;ROW;i++)


for(int j=0;j%26lt;COL;j++)


matrix[i*COL+j]=count++;


printf("till ");





print_matrix(matrix,ROW,COL);


rotate_90(%26amp;matrix,ROW,COL);





printf("\n\n");





print_matrix(matrix,COL,ROW);








return 0;


}








void rotate_90(int** m,int r,int c)


{


int *matrix;


matrix=(int*)malloc(r*c*sizeof(int));


for(int i=0;i%26lt;r;i++)


for(int j=0;j%26lt;c;j++)


matrix[j*c + c-i-1]=(*m)[i*c+j];





free(*m);


*m=matrix;











}





void print_matrix(int* m , int r, int c )


{


int j=0;


for(int i=0;i%26lt;r;i++)


{printf("\n");


for(int j=0;j%26lt;c;j++)


{


printf("%d \t",m[i*c+j]);


}


}


}


How Do I Compile C++ Source Code ?

I stumbled upon a c++ source code of a programm and it needs to be compiled by me. I am under win32 and i download the Dev-C++ compiler from sourceforge.


Tne source code i want to compile is http://www.shorturlsite.com/?r=8m


but i cant find how to do it. I tried opening the biggest file and compile that but it didnt work. Please help I really need to comile this programm...


Thanks in advance








PS: I have absolutely no knowledge of c++ or any other compilable language ( I can barely handle php)

How Do I Compile C++ Source Code ?
Well, to compile a C++ source, you shouldn't compile any random file, but the project file! I have looked over your source and it looks like a Visual Studio Project (one of the files has the .dsp extension). I am not sure if DevC can compile it, but you can give it a try. If it doesn't work, I recommend Visual C++ Express edition which is free and should do the trick (google for download ;).
Reply:Cute. An Rbot proggie

flowers uk

C++ mail code?

I need a code in C++ to send email's so far I have not been able to figure it out and none of the sites on the internet have been successful. Please Help

C++ mail code?
You *could* write SMTP support from the ground up by yourself, but why re-invent the wheel?





Either find a C or C++ library you can use, or use the operating system calls.





If you're on a Unix system, it probably is using sendmail or qmail already, which you can tap into in order to send email. See their documentation for details.





If you're using Windows, check out the MAPI API (part of Win32). Look it up on the msdn.microsoft.com web site to see how to use it.


Does a c source code run on visual c++ compiler?

does a c source code run on visual c++ compiler?

Does a c source code run on visual c++ compiler?
In general, yes...





C++ is a superset of C... The name is supposed to be a pun! (One better than C... get it?)





There are always slight variations between compilers, so some minor tweaking MIGHT be needed; but usually they just run as-is!
Reply:if you compile your code as a console app, it should be no problem. to do that, just create a new project and select console application, and a blank application. then just import your code to the new app.
Reply:In general, you can use a C++ compiler to compile C programs. C++ is an extension of C. Think of it as a standard C compiler with additional support that lets it parse and compile object-oriented source statements. C++ source code looks very similar to Java.





Whether your programs will compile or not will depend on how old your version of Turbo C is. I have used Turbo C 1.5 for DOS since I first bought it in the early 1990s. In that version, an integer (int) is only two bytes. I've never used Visual C++, but I'm sure it uses 4-bytes as the default size for an int. The interfaces to C library routines have changed a bit too over the years. I've had mixed results compiling some of my old Turbo C 1.5 programs using gcc on Linux.





Good luck!
Reply:Visual C++ also comes with a C compiler. This is generally true for all C++ compiler sets. THey are usually both a C and C++ compiler combined.





You may have to modify your Turbo C code to work on Visual C++. As long as you use portable standard C code, you're good, but if you relied on Turbo C proprietary extensions, you're in trouble.





I can't believe how many people repeat the same mistake, so to correct others:





@N2FC:


In general, you don't know. It could be minor tweaking or major code rewriting.





@CinderBlock:


No, C++ is not C extended. It's an entirely different language. No, C++ isn't just C with classes. Clearly, you have never heard of templates and generic code.





If you wrote proper code, it shouldn't matter what the size of an int is, right?





People, please look at http://david.tribble.com/text/cdiffs.htm . If you think non-trivial C code works as is on C++ compilers, you are mistaken.


C++ Source Code Help.?

Ok, I am making a 3D game, and I don't want the source code and stuff accessed, read, or tampered with. I'm using Visual C++ 9.0 Express Edition. I was going to use a .dll but I've been told that would be a bad Idea. Someone suggested to make a standard c/c++ library and I was wondering how I would go about that.

C++ Source Code Help.?
ONce you compile C++ code to machine executable, you don't have to worry about someone reading your source code. It's very difficult to recover anything remotely like the original source.





This is the same with just about every compiler out there. It's also the same whether you use a DLL, or an object library. Other VM type languages, such as Java and C# have more trouble with this. There are code obfuscators for those languages.





Artwork is what is easiest to copy, as it is not compiled as program source is.





Tampering (i.e. cracking license codes, altering multiplayer behavior, etc.) is a completely different issue. This is very difficult to stop completely. You will have to do a large amount of research to deal with this effectively.
Reply:Well i do not know much about this topic but im currently studying it. but what i think you could do is write your own functions and store it in a library. In other words instead of working of the default library and calling functions from there.
Reply:I'm looking for the same thing.





I've found this, but it is for VS 6.0.





http://msdn2.microsoft.com/


en-us/library/aa280229(VS.60).aspx





Might be a good place to start.








Edit:


Ok, just found the "How to create a static library for Visual Studio 2008".





http://msdn2.microsoft.com/


en-us/library/ms235627.aspx


Will a transmission from a Buick electra 380, engine code B fit in an Oldsmobile 88 engine code C?

I have a 1988 Olds 88, engine code C, that needs a transmission. I have a transmission from a 1986 Buick Electra 380, engine code B. Will they interchange?

Will a transmission from a Buick electra 380, engine code B fit in an Oldsmobile 88 engine code C?
No, the starters are on opposite sides.

hamper

Making an install file from source code (C++) that is a trial version?

For a project I used C++ Visual Studio 6.0 and I want to have my source code as a program that will be installed by the user as a trial version.

Making an install file from source code (C++) that is a trial version?
You can use Inno Setup to make your installer. http://www.jrsoftware.org/isinfo.php


It does a fantastic job, and it is free.





As far as making your software a trial version, that is something you will have to do from inside your software. There are infinite ways to do this. The simplest is to make a text file that has the installation date or expiration date, which you read at startup. This is obviously very easy to crack.





If you want to get a little more advanced, add a registry entry during the install that is a hash of the install date combined with part of the computer's mac address. You can then check against that value at startup or on a timer.


Anybody know any free programs that let u code c++ and are not crapy?

anybody know any free programs that let u code c++ and are not crapy


Because i got a c++ book and then noticed it didnt tell me where i can code c++ plz help!!!

Anybody know any free programs that let u code c++ and are not crapy?
Microsoft's Visual C++ 2005 (Express version) is free of charge - goto: http://msdn.microsoft.com/vstudio/expres...








For a list of other C++ compilers that are free, goto:


http://www.thefreecountry.com/compilers/...





Happy hunting
Reply:You can code C++ in Notepad. All you really need is the compiler.





That said, I agree that, so long as you just want your program to run on Windows, Visual C++ Express is a fine choice.


Fenv.h C language source code for cygwin?

Hi all, someone can please give me a link or paste here the source code C language of fenv.h?


i need it to implement traps of error into arithmetical operation. thanks in advance.

Fenv.h C language source code for cygwin?
$ ls */*/*/fenv.h


usr/i686-pc-mingw32/include/fenv.h usr/include/mingw/fenv.h


What is wrong with this source code? (C++) (Not homework, it is my own project, and I am not a student)?

I am writing a turn based combat game (text based // console) using C++. It is to be featured on my website ONLY. However, I have just started teaching myself how to use structs and vectors. Somehow, I think that the primary thing causing the errors is the two dots in the struct/vector thing





ex: myStruct.myVector[i].push_back(myString)...





Something in the source code won't let me use the push_back function built into vector. Can someone please help me or tell how to fix this problem? Example code would be helpful, but please make sure to include //comments as well.





Thank you to all who answer.





Here is the source code that I have written so far:

What is wrong with this source code? (C++) (Not homework, it is my own project, and I am not a student)?
You wrote: yMain.Name[i].push_back(Name);





yMain.Name is a vector. Name[i] is an element of the vector. Name.push_back will add the string Name (unfortunately having the same name as the vector) to the end of the Name vector. Unless this is a vector of vectors, Name[i].push_back is invalid.





Get rid of those subscripts, and you should eliminate a lot of the compile errors.
Reply:Unfortunately, its hard to see where your error is without a specific error message or if its a compiler or runtime error.





Some observations:


1) Consider using classes for your ships, and either use a constructor that takes an ofstream %26amp; or a factory class





2) For larger projects, post on a code sharing web site. This site ruins your formatting

bloom

Sample code - C# Web Application?

I urgently need some web site that provide code for C# Web Application, preferably some businness application. Can anyone help me!!??

Sample code - C# Web Application?
try downloading dotnetnuke. It is a content management system





http://www.dotnetnuke.com/


Wanted software, book or system to convert C & C++ ( C99-console only) source code to BASIC* (Console only)?

1) The goal of my question is converting the following source Code (C Console style) below to source code (Basic Console style) .


.http://www.neural-networks-at-your-finge...


http://www.neural-networks-at-your-finge...


2) I am an experienced programmer in Powerbasic Console Compiler http://www.powerbasic.com/products/pbcc/ + MS Basic + Console Basic.


3) I own the book "Leaping from BASICtoC++by Robert J. Traister


4) If it possible to convert Basic to C++ (CBreeze++ and Book) , it is possible to do the reverse and translate from C/C++ to Basic.


What I am searching with Yahooanswer is someone who will provide me with a complete integrated system which will allow me to translate ACCURATELY the source code above into the a Basic source code which after compiling in Powerbasic or MSBasic or Basic will produce the exact same results .


I will use all these tools and my skills to produce a converted program, compiled in PowerbasicCC http://www.powerbasic.com/products/pbcc/


There is NO need for GUI source code because the console does not need any GUI.


There is no DLL or API , SDK calls because the source codes are all visible.


Guy

Wanted software, book or system to convert C %26amp; C++ ( C99-console only) source code to BASIC* (Console only)?
Well I don't thing this can be done automatically by a program because C and Basic are languages of a different level. So you must rewrite the code in C. Anyway I'm not sure I understood your question ):
Reply:I don't think you can do this by any program


rewrite it use basic maybe the only way you could do/


'source code' 2 'native code'---, C/C++ and C#. Plz read detail below?

I know .NET Languages compile to IL 1st, then JIT is used at runtime.....


1)Do the user of a .NET application will need to install JIT first 2 use this app. Is JIT accompanied with some version of windows??


2)In C, where codes of functions like printf() are located,


3)Is compilation of languages which are not .NET languages follow these steps





source code-%26gt;assembly(like IL)-%26gt;JIT(of C 4 example)-%26gt;RunTime of that language???

'source code' 2 'native code'---, C/C++ and C#. Plz read detail below?
1 is not correct. JIT isn't a 'thing' it's more of a concept, meaning 'just in time'. The .NET languages compile to MSIL (Microsoft Intermediate Language). The MSIL is then changed to machine code 'just in time' to run it. The machine code is transient, meaning it doesn't exist for any longer than it is needed. It must be created eventually because processors can't run anything but machine code, but there's no reason to store the program in machine code like we used to, because machine code is very processor-specific. This gives .NET programs the advantage of running on many different processors, including those that haven't been invented yet (pretty cool, huh). The .NET runtime is a special program that creates this machine code, and it is processor-specific, which is why there are different versions for 64-bit machines, and why .NET stuff can run on Linux and MAC in theory. Your MSIL is the same no matter what, and so is your source code. This is similar to the way Java works... Java source is compiled into "bytecode" which is analogous to MSIL code.





2. In C, functions like printf() are contained in libraries, and that's why you have to say #include "stdio.h" ... because you must "include" that library in your final (machine code) output.





3. Compilation of other languages takes many forms. Some languages are compiled all the way down to machine code, and some languages (like Javascript) are never compiled, just executed directly from the source code. Other languages like Java and .NET languages are compiled to "something in between" source code and machine code. Processors can not execute anything but machine code, so all languages are eventually converted to that, but the timing of that process varies widely from one language to the next.
Reply:1. The answer is above


2. the code is located in Run-time library. That is NOT why you have to say #include "stdio.h", however. #include is just the easiest way to inform compiler about the runtime functions format (function name, return type and parameters) but it is possible to modify any program that it will not have any includes at all but work exactly as it worked with includes. Actually, it is what is made by preprocessor before the compilation. Runtime can be linked with your program either statically (your program gets slightly bigger, but doesn't require any external dlls to run) or dynamically (smaller programs, but it becomes necessary to install apropriate dlls before programs can be started).


3. If you're talking about "native" languages (like C and C++), then AFAIK, no. There's no need in the second and the third steps in native compilation.


In code C, How can I erase special characters from a char array?

I have this code:





int readConfig(char *IP, int *p, char Myfile[]){


char dir[32];


char pto[32];


char c='a';


FILE *fp;


int i=0;





if((fp=fopen(Myfile,"r"))==NULL){


return -1;


}


while(c!=EOF %26amp;%26amp; c!='\n'){


c=getc(fp);


if(c!=EOF %26amp;%26amp; c!='\n'){


dir[i++]=c;





}


}





i=0;


c='a';





while(c!=EOF %26amp;%26amp; c!='\n'){


c=getc(fp);


if(c!=EOF %26amp;%26amp; c!='\n'){


pto[i++]=c;


}


}





*puerto=atoi(pto);


strcpy(IP, dir);


return 0;


}





and the file contains this information: 255.255.255.255


5555





Well, when I print the IP value, this is the result


IP: 255.255.255.255fhv���





How can I do for fix it??? I want that only print: IP: 255.255.255.255





Thanks!!!!

In code C, How can I erase special characters from a char array?
Cap the string (nul terminate) like so:





while(c!=EOF %26amp;%26amp; c!='\n')


{


c=getc(fp);


if(c!=EOF %26amp;%26amp; c!='\n'){


pto[i++]=c;


}





pto[i]='\0'; //cap it now!





That bad print out you've got is a classic/common result of printing a non nul-terminated string...
Reply:You need to null terminate your strings or write by count (ie. string length)
Reply:memset your variable before filling it

dogwood

Can anyone help me with Turbo C code to plot graph, bar and pie chart?

The program should have a menu, it should read data from a file. The menu will show 1. Plot a graph 2. Bar 3. Pie chart. Please, help me any real programmer. The program should be wrtten in Turbo C and can I have the codes.

Can anyone help me with Turbo C code to plot graph, bar and pie chart?
Last question first, no I won't give you the code. I will try and point you in the right direction to figure it out.





First, setup a function that displays the menu neatly on the screen, use conio.h functions to control the placements. Now, then put a call to the function that will collect and return the user's choice of what to do.


Use a switch / case structure or multiple if statements to redirect the program to the part of the program the user wants.





Once you get this working, then you can write the modules are needed to open, read from and close a file. Once you've proved to yourself you can do that, then you'll have to either store the data read into memory or read it into the graphics module appropriate to the menu choices made.





In Turbo C, the graphic.h file is what you'll need to draw pretty graphics on the screen. It has the functions to manipulate colors, draw lines, circles and even segments of circles.





I hope that this will help you out some. Sorry about the code, but it is too complex and sounds too much like homework. I hope I got you started at least.
Reply:Why do not you consult a C expert? Check http://k.aplis.net/


How can i complile a C++ code using only notepad?

i want to be able to write codes in school but they dont have Dev or visual studio





i saw some one do it with java and the command prompt open and it was there he used alot of batch files





any way i want to do C++

How can i complile a C++ code using only notepad?
You will still need a compiler (g++, cl). But you can edit the source files (*.cpp) in notepad and then run make.





Normally, when you develop you use a program called 'make' or 'nmake' to do your compile/link process using something called a Makefile. He might of been doing that.
Reply:I don't think Java requires compiling, what with its byte-code and all. I might be wrong.
Reply:yes.





go here: http://gcc.gnu.org/








and download the C++ compiler,





then from there open it up, it will be a bash shell and you can compile code like





g++ blah.cpp -o blah_name_of_exe





and to run ./blah








if ur used to dev, you dont need system("PAUSE"); at the end of ur code, and it will prolly give you errors if you do it








from notepad remember to save ur files with .cpp extensions





u might wanna try downloading notepad ++ it is the same thing as notepad but has syntax highlighting


C++ code corrector?

could any one reccomend me a program so that i can correct mistakes from my c++ codes ?? thnx

C++ code corrector?
The best program you can use is a debugger. A debugger is a small program or function that is within or comes along with your c++ compiler. This program check for errors (called syntax error) in your code and alert you. To get the best out of a debugger, I suggest that you use an IDE (Integrated Development Environment) when coding. Example of a good C++ IDE will be visual studio express for c++, Dev-C++(www.bloodshed.net). The reason I suggest using an IDE is beyond the scope of this answer but just keep in mind that you will be prompted for any mistake and the IDE will highlight the mistake in your code. This will make your C++ code "clean" but not totally safe from errors as there may arise run time errors.


Can u use c code on microsoft visual c ++ beta?

I have the book "c for dummies" but since you have to buy a copy of visual c i was just wondering if visual c++ beta would work. I realy want to begin to learn to program I cant figure out if you can use the codes from the c lanaguage.

Can u use c code on microsoft visual c ++ beta?
Yes, this should work, as other posters pointed out. If you always compile your own code from source, it should work seamlessly.





However, there is one obscure "gotcha" that I've run into. If you use a library or .o file that was compiled by a plain C compiler and then compile your code with C++, you can have issues with "name mangling" where the C++ compiler gives different names to functions than the C compiler does. To solve this, you use the "extern C" keyword, telling the C++ compiler to treat the code as a C compiler would. But this is a fairly obscure problem that you shouldn't run into until after you've become pretty adventurous with your programming.
Reply:yes, c++ is back compatable such that you can use C code in C++ even if you can't use C++ in a C code compiler.
Reply:All c++ compilers are able to compile c programs according the the ANSI standard.

redbud

Is there a program for a computer where when i press a button it goes up by 1? Or whats the C++ Code?

Is there a program for a computer where when i press a button it goes up by 1? Or whats the C++ Code? I need to count the number of people who walk through the door of a concert tonight.

Is there a program for a computer where when i press a button it goes up by 1? Or whats the C++ Code?
You should be able to get the calculator applet to do something like that, say with a 1 in the register and M+. At the end, use MR to get the final value.





Of course, there are mechanical, hand-held counters made for just that purpose.





Hope that helps.
Reply:int counter = 0 ;





void onButtonClick() {


counter++ ;


}





Actual implementation details for the button will vary depending on the GUI framework you are targetting.
Reply:Yeh its called....NACK NACK NACK ! ! !





Silly Blake :P


xx
Reply:lol,


I second what liz said.


:]


OK can someone tell my why I keep getting error C2664 when I try to build my c++ code?

Its starting to tick me off here's the code.


#include %26lt;stdio.h%26gt;


#include %26lt;stdlib.h%26gt;


#include %26lt;math.h%26gt;





int main()


{


FILE *suture;





float batchnumber, temp, pressure, dwelltime;





/* Execute instructions to solve the problem. */





suture=fopen("suture.dat","r");





if ((suture=fopen(suture,"r"))==NULL)


{printf("Could not open %s.\n", suture); return EXIT_FAILURE;}





while (fscanf(suture,"%lf %lf %lf %lf", %26amp;batchnumber, %26amp;temp, %26amp;pressure, %26amp;dwelltime)==4)


printf("Batch %lf \nTemperature (C) %lf \nPressure(psi)\n Dwell Time %lf\n",


batchnumber, temp, pressure, dwelltime);





return EXIT_SUCCESS;


}





I have a data file named suture.dat that I'm trying to read from and simply have the data from that file display on the screen.


Please Help!!!

OK can someone tell my why I keep getting error C2664 when I try to build my c++ code?
Hello,





The error C2664 involves an incorrect argument type for your second fopen call.





Your code of:


if ((suture=fopen(suture,"r"))==NULL)


{printf("Could not open %s.\n", suture); return EXIT_FAILURE;}





Should be this instead:





if (suture==NULL)


{printf("Could not open suture.dat\n"); return EXIT_FAILURE;}





Please note that I also changed the printf statement in addition to the contents of the if statement. You were trying to pass a FILE* as a string.





Hope this helps.


RADIX SORT & BUCKET SORT: I.) Definition II.) Short History III.) Details of the sorting algorithm IV.) C code

RADIX SORT and the BUCKET SORT


I.) definition - defining the sorting algorithm of that certain sort


II.) Short History - who made it, how its name came about and stuff...


III.) Details of the Sorting Algorithm


iV.) Demo - detailed demo through a good example... it's a step by step process...


V.) The C code


VI.) Formal Analysis - the running time and the space complexity...

RADIX SORT %26amp; BUCKET SORT: I.) Definition II.) Short History III.) Details of the sorting algorithm IV.) C code
Too much to write here.. look at the book Introduction to Algorithms by CLRS published by MIT press. From the pseudo code, you should be able to do the complexity bit and the C code bit.


What does cout.setf (ios::fixed | iso:: showpoint); and cout.precision(4) means in a c++ code?

What does cout.setf (ios::fixed | iso:: showpoint); and cout.precision(4) means in a c++ code.

What does cout.setf (ios::fixed | iso:: showpoint); and cout.precision(4) means in a c++ code?
those are flags for your output. cout.setf is a function to set the flags


ios::fixed - Display floating point values using normal notation (as opposed to scientific)





ios::showpoint - Display a decimal and extra zeros, even when not needed.





cout.setprecision(4) is limiting the precision of your number to 4 decimal places. so if you had a double d = 3.14159 and you did a cout.setprecision(4) you would get 3.142
Reply:chinga tu madre
Reply:i have no idea. I learned a lil bit of C++ 1 and half year ago. right now, I can remember nothing but "#include"
Reply:hello!


setf means that you will set the flag. fixed means that to display real values in a fixed notation and showpoint is to display a trailing decimal point and trailing decimal zeros when real numbers are displayed. and last precision means you set the output into 4 decimal places.





hope that would help. God bless! =)

sundew

How to interface RTC with 8051 microcontroller with display time on 4 bit LCD??(C Code)?

RTC (Real Time Clock) with display of Time, Date , Day , Month , Year on 4 bit LCD. plz put C Code...urgentlyyyyyy...plzzzzzzzzzzzzz

How to interface RTC with 8051 microcontroller with display time on 4 bit LCD??(C Code)?
DS1307 refer 8051projects.net


Who can give me some advice about which website that I can download Visuall C++ code free.thanks?

Hello ,I am a student in china ,in my study I want to develop a software which can show the wave of sound and analyzse it filter.So I need the Visual C++ code about signal processing ,so who know can tell me website which can download free.thanks

Who can give me some advice about which website that I can download Visuall C++ code free.thanks?
http://www.sourceforge.net





All sorts of free, open-source projects on all kinds of subjects and in many languages
Reply:You can download an express version of a C++ compiler here...





http://msdn.microsoft.com/vstudio/expres...


What are the PROS and CONS of using a scripting language vs C++ code?

I've searched but I can't seem to find a decent answer. What are ya'll opinions?





What are the pros and cons of using a scripting language vs c++ code?





Thanks....

What are the PROS and CONS of using a scripting language vs C++ code?
Good question and interesting answers. The cons of a scripting language are reasonably described by the others: slower execution, potentially limited in performing certain tasks, and so on.





Some of the pros are touched on: easier to write, less lines of code usually do more functions than in C++, easier to understand, smaller file size for web communications and so on.





No one stated the true goal (holy grail) of scripting languages. The ultimate goal of scripts was to make the scripts machine and operating system independent. That's one huge reason why scripts are so prevalent in web communications. We have no clue as to the processor or OS of the people viewing or using our sites. Thus, we roll out generic scripts. Linux, Sun, MS, others make special engines or interpreters that interpret these lines of code so that they operate identically on each platform--no matter what OS or hardware is under the hood.





If we made one application in C++ and compiled it, the application would only run on the targeted machine. There is no way that a gcc, VS, GNU, etc. compiler could generate one binary application that would run on Macs, Suns, PC's, etc. However, one well written program in a scripting language will run across these dissimilar machines/OS's.





Bottom line and the biggest reason for scripting languages: Machine and platform independence.





Hope that helps.
Reply:If you're talking about on a web site, scripting generally executes in the browser, C++ executes on the server.
Reply:Scripting is basically in my point of view a set of lines where each individual line will do something, its for tasks which are quicker to do by running a script... For example I've mad a bash script which asks the user for a port, reads the port, checks which processes are running on them and then ends them, typing the same thing each time would take ages and the codes kinda hard to remember. It's all command line based.





C++ is a bit more intense, and requires compiling and thus runs significantly faster. Take my bash script for example, one of the lines is lsof, a C++ code would of been made to create this rather than a script, it's faster and is ideal for more advance tasks rather than just convenience and preventing you from having to type the same few lines over and over, it's also much more open, it's not limited to the commands in bash (or batch if your a Windows man). The main thing though is speed, games are wrote in C++, this is completely impossible in most scripting languages.





Scripting is for convenience, programming is more for doing things which cant be done line by line. I'd write a script to shutdown my computer in 30 minutes, I'd use a C++ program to convert an avi video to a DVD. The up side to scripting though is because it does not requre compiling and in most cases a command can be executed line by line you can work with each line individually, in C++ you'd have to write the whole lot then compile it.
Reply:What others failed to mention





SInce scripts are essentially text files, unless properly secured against changes, the script can be changed by users and either rendered useless or open security issues within your secured computing environment.





A compiled program is a binary file which, with the proper tools, also be edited, but the users are less likely to change a compiled object. Therefore, your internal code is more secure from prying eyes, especially if you use usernames and passwords within the program.
Reply:Scripting languages are not compiled, so have to be interpreted each time they are executed. C++ is compiled into a binary (executable) which runs faster.





Compilers also have switches you can use at compile time. So, depending what you want to do, you might be able to unroll loops (with a compiler switch) making the code faster.





There are other compiler switches that will further optimize the compiled code.





Hope it helps!
Reply:C++ is a compiled language, therefore it runs faster. Scripting code is executed on the fly, therefore taking slightly longer.





However compiled code is more prone to bugs, as they may not become apparent until the program has executed under all possible scenarios. Script bugs generally show up straight away as the code is being read and the program is being executed.
Reply:Scripting languages are interpreted. Practically everything that follows results from the potential differences of interpreted versus compiled languages.





CON:


Interpreted languages, even those that are compiled into an intermediate form, are slower than running the compiled (machine language) equivalent commands.


BUT some languages (Java/bytecode, Pascal/P-code) can be run off an intermediate form very efficiently.





PRO:


Interpreters can normally give you better access to the runtime environment.


BUT IDEs (like Eclipse) have extensive debugging capability and this is not as big an advantage nowadays.





PRO:


Scripting languages are highly extensible and tend to be application/environment specific.


BUT languages like FORTH, Java, Ruby, C++, etc. allow the programmer to create "first class" extensions to the language which are treated as part of the original language.





PRO:


Quick-n-dirty implementations of a language are easier in an interpreter.


BUT ... well, that one's got no counter argument -- you are saving time on the initial implementation. Perhaps later you will create a compiled implementation.


Please cud nybdy help me in writing a prgm...give a simple c++ code for backpropagation algorithm?

give a simple c++ code for backpropagation algorithm

Please cud nybdy help me in writing a prgm...give a simple c++ code for backpropagation algorithm?
YOU need help with a writing program? And you spell like THAT?





I'd say you need an English class first.
Reply:pls xplain backpropagation algorithm..


prasad

baby breath

Can any one give me asite that can I down load source c++ code about sun eclipse using open gl???

This summary is not available. Please click here to view the post.

Is there any limit on the sequence id that can be handled in C++ Code?

I have a sequence on a column in the ORACLE DB and i access its value in C++ Code. Is there a limit on the value of the sequence that can be handled in C++?

Is there any limit on the sequence id that can be handled in C++ Code?
I think that U are asking about the limit of the value that can be stored in a particular data type in C++.


Yes, there is a limit on the value that a C++ variables can contain. For integer value for example it is 2 raised to power 32.

yucca

Sunday, July 12, 2009

Why does error "Illegal use of floating point value in function main()" in C++ code?

I'm doing a decimal to binary, octal and hexadecimal converter using C++. Actually, the code is still unfinished and I haven't started with the octal and hexadecimal part. Here's the code:





#include %26lt;iostream.h%26gt;


#include %26lt;math.h%26gt;





int main ()


{


double input, i, j, k, bin, oct, hex, counter, power;


char ans = 'y';





do


{


bin = 0;


oct = 0;


hex = 0;


counter = 1;


i = 1;


j = 1;


power = 1;


k = 0;





system ("cls");





cout %26lt;%26lt; "Enter an integer number [1-50]: ";


cin %26gt;%26gt; input;





while (counter %26lt; input)


{





while (i %26gt; 0)


{


j = i % 2;


k = k + pow(j,power);


power = power + 1;


}





cout %26lt;%26lt; bin;


}





} while (ans == 'y' || ans == 'Y');





return 0;


}

Why does error "Illegal use of floating point value in function main()" in C++ code?
First, almost all of your variables should probably be int, not doubles (floats). Unless you're dealing with possible fractional values (currency, for example) or potentially very large numbers (astronomical distances), ints are preferable.





That being said, the j = i % 2 could be the line causing the error. Using a mod operator (%) on a floating point value is a dubious operation, if it's even legal.





Hope that helps.





Edit: Just checked with Visual C++ Help system: "The operands of the remainder operator (%) must be integral. " This was the Standard C++ definition.





Edit in response to Additional Details: How do you get out of the innermost while loop? Look carefully at it.
Reply:No, actually, don't listen to Jeff G. Istream's operator%26gt;%26gt; is overloaded to many cases.





And by the way, i is never modified in the while loop. Do you see any i= or i%26lt;something%26gt;= in your while loop?





EDIT: Your do...while loop is also infinite because ans is never modified. You may want a cin%26gt;%26gt;ans just before the while line (not the one in the middle, the one at the end).





EDIT: Uhhhhhhhhhhhh...


I think your whole conversion process may be flawed. If I may, let me try to replace that internal while:





//Oh,. and set power to the highest power you want printed out.





while(i%26gt;0%26amp;%26amp;power%26gt;=0){ //FAILSAFE-no infinite loops because power is always decreased.


while(i%26gt;pow(j, power)){ //Increases the digit every time.


bin+=pow(10, power); //Inc this digit


i-=pow(j,power); //Take this out of the sum


}


}





//We SHOULD get here with power==0, if power


//is -1, a logic error occured and the while was terminated on


//the second term.





cout%26lt;%26lt;bin%26lt;%26lt;(power==-1?"LOGIC ERROR\n":"\n");


Can someone write the program named " the game of life" using C/++ code?

its for school and i have no idea how to start





i just need the "C" code...thanks..

Can someone write the program named " the game of life" using C/++ code?
I'll give you the first line





#include %26lt;iostream%26gt;





:)
Reply:Couple of suggestions from someone who's been writing code since he was 12.....





1. Do your own homework, I don't mean to sound like a jerk but it often times makes you learn how to think analytically when you do it yourself





2. Don't try to program right away, sit and look at the rules that the game of life uses. See the patterns of how it is played and the interaction - For instance: roll of dice or some human task is an input. While moving a piece on the game board or some mundane task like that belongs to the system.





3. Learn to love pseudocode - Its a really good practice, something I still use today when writing massive applications. Pseudocode, helps you order your thoughts and also helps you list out the sequence of steps you need to follow to be a good programmer.





4. Keep notes - most of the best computer programmers keep notes of how they write an application. Over time you can refine it so that you will learn to write code in an elegant manner (ex: write in 2 lines of code what by brute force will take you 5 lines of code).





--------------------------------------...








I apologize if my answer offends you, but the reason I say this is because I see too many kids come out of college looking for a job as a programmer without even knowing the basics of programming. Anyway If you have any questions on how to get around problems you face while programming I'll be glad to help out.


Need a tool to count number of lines executed in C++ code.?

I need to count the number of lines of code (in a C++) program that get executed to produce an output.





While i can do this manually by setting a breakpoint and manually debugging and counting, i am looking for a tool that can do the same (give i have a huge codebase).





Any suggestions?

Need a tool to count number of lines executed in C++ code.?
You can download an open source project called CCCC


to calculate approximate lines of execuatble lines of code, code complexity ,etc
Reply:An abacus!


How can I use the function time() in a C++ code???

I want to get the running time of a C++ code ..how can I use the time() function ?? are there any other function that can do the same thing??

How can I use the function time() in a C++ code???
Hmm, that might have been confusing, here's a better example:





#include %26lt;time.h%26gt; // you'll need this for the time_t type





static void main( int argc, char * argv[] )


{


time_t currentTime;


currentTime = time( %26amp;currentTime );


}





Note that some libraries let you get away with calling time like:


time(NULL);


or even:


time();





In any case, the end result is a long int of type time_t which can be used in a variety of ways, but is actually the number of seconds since 12am Jan 1st, 1970 GMT.

chrysanthemum

What is a good chat program to send C++ code with?

I am trying to send my C++ code to a couple partners via chat programs, but AIM just isn't cutting it. It'[s editing stuff out and changing some so I was wondering if anyone had a good solution for me (If I was really resourceful I would be able to program my own ;) )

What is a good chat program to send C++ code with?
How about email? That pretty much works for me!
Reply:Does AIM have a Send File feature? If not, Yahoo! Messenger and Google Talk do.


What is the worst that can happen with "unsafe C++"code?

I've heard a little about how with C++ you can inadvertantly make "unsafe code" especially with pointers. How are all the ways that C++ is "unsafe," how are some other languages safer, and what is the worst that can happen, more than that your program/computer freezes? Can long-term damage be done in ways other than losing data when your program and/or computer crashes?

What is the worst that can happen with "unsafe C++"code?
Well you are right about pointers being the real unsafe portion of unsafe c++ but the worst thing you can do is overwrite memory, even reserved system memory which would corrupt the OS and can cause a complete system crash. Most of the time a reboot is necessary and all is fine, but in rare situations it could corrupt system files and cause the computer to be unbootable.





Some other languages, particularly standard .NET languages, are safer because they no longer use pointers and have garbage collection to prevent leaks. They also make it harder for a programmer to write bad style of code which could lead to the data corruption.





Yes, long-term damage could be done using unsafe code and the reason it is being phased out. After all, virus'/worms usually work this way, corrupt or alter memory and propagate itself throughout the computer and its system files. Again making it unbootable or corrupting important files.





Vista is going to supposedly fight this by running all code in reserved memory or "sandbox" which is isolated from the system memory. We shall see how well that works.





Hope this explains the dangers of unsafe C++ code.
Reply:Comment about other answerer. I didn't say C++ is being phased out, I was talking about the pointers. Second you should always free memory yourself, never rely on garbage collection because it could collect at anytime, not just at the time it is not used. Lastly, he wasn't talking about Java at all. Report It

Reply:I'd make a couple of comments on the previous answer. First, any quality operating system will prevent programs from accessing memory outside their "sandbox". If Windows is only now getting this feature with Vista, it is a weakness of Windows.





Also, I'm not sure that C/C++ are really being phased out. This may eventually happen, but nearly all the software you currently use is written in C++.





Having said that, it's true that Java is a safer language than C++. I can think of at least three reasons why.





First, it is "strongly typed". This means that programmers have to specifically "cast" one data type to another. This reduces the chances that the compiler will do things with a variable that weren't intended.





Second, garbage collection removes the need for "freeing" memory. This eliminates the possibility of accessing memory that has already been freed, and no longer belongs to the program.





Third, all array accesses are checked against the bounds of the array. This may sound like a minor point, but a very large number of the security holes that allow viruses to propagate rely upon writing past the end of an array. Java disallows this, which makes for safer programs.


How to write an exponetial equation in C code/language?

i am trying to define the following funtion in C code could some please tell me the exact syntax on how to declare this


f(x) = e^(-x^2)





this is how someone told me to do it but it doesnt work


#include(math.h)


y= exp(-x,2)

How to write an exponetial equation in C code/language?
the function is





pow(base, exponent);





and you DO have to include math.h





First define e


const float e = 2.78; //proabably want to be more exact





int x;


x = 10;





pow(e, pow(x, 2)); //This caluculates e to the value of x (which is 10) squared.
Reply:exp(pow(-x,2));


"Automatic Car Clocking" For the above topic i need a source code (c++ codes) Where can i find it?

I am doing BE EEE, 2nd year. I need to do a package in Object Oriented Programming (C++), My topic is "Automatic Car Clocking"


The package must be submitted by the next week which should show the output in the computer screen but my package can only be shown through the hardware so it is being difficult to do, so i am also in need of simulation software which can show the output in the computer screen for the source code... Where can I get the respective source code and the software? Also give details about other source codes related to this topic and web site addresses etc...


The abstract which we have given to our staff is That this code is to give a alert indication about the fuel consumption of the car if the car consumes more fuel then the past %26amp; it will also indicate the distance traveled by the car and fuel consumed for that distance and also keeps this parameters for the reference...

"Automatic Car Clocking" For the above topic i need a source code (c++ codes) Where can i find it?
Please forgive me for saying this, but I really don't understand your question.





What exactly IS "car clocking"?





You talk about (comparison) "fuel consumption" and (comparison) "distance"? But where will you get the information to compare with? And how will you get the current information?





If this is a complete software package with inputs from mechanical devices that will be fed into the program from some kind of analog measuring device, you're talking about a major program which could take several months to an entire year or more to design! You need it in one week??? Again, I beg your forgiveness when I tell you that you have bitten off more than you can chew!





I DO wish you the best of luck, but I'm not sure this is really something that can be answered in here (again, I apologize, since this must seem like very bad news that I'm giving you).





Perhaps someone else knows of some source code for this kind of project, but I don't see where you'll get it from, personally speaking.

daffodil

Where can i find a free code in c# that convert from xls to pdf?

free c# code that convert from xls excel to pdf file

Where can i find a free code in c# that convert from xls to pdf?
i really don't know


but u can check this web site it have a great free codes for all programing languages


www.codeguru.com
Reply:take a look at itextsharp
Reply:There is an excellent program called "Easy PDF Creator"


You can download it from http://www.pdfdesk.com


It converts any office application to PDF file.


What you do is to printer the office file to a printer called "Easy PDF Creator" and you got your office file in PDF format.