After a C++ program, is there any way to make it not say press any key to continue...? I am using Dev-C++ 4.9.8.0.
HELP!!!!!!
After a C++ program, is there any way to make it not say...?
that is just the debugger running it. Run it normally through a normal DOS console or command prompt and you won't see it. Basically that is there to keep the window from closing without user interaction.
Sunday, August 2, 2009
Problem on C program(strings)...please try to solve.?
write a C function void str_copy_drop(const char * string1, char * string2, char ch)
which copies the string string1 to string2 but with all occurrences of the character
passed as parameter ch omitted.
HERE IS WHAT I HAVE TRIED: its funny but can you check it and write me a correct program..
#include%26lt;stdio.h%26gt;
#include%26lt;string.h%26gt;
void str_copy_drop(const char *string1, char *string2, char ch);
void str_copy_drop(const char *string1, char *string2, char ch)
{
char *s1[20],*s2[20];
FILE *input;
input =fopen("string.txt","r");
fscanf(input,"%s",%26amp;s1);
s2= strcpy(s2,s1);
printf("\ncopied string is %s\n",s2);
}
above programs is wrong...i need solution for question described above..
Many thanks!!
Problem on C program(strings)...please try to solve.?
Use this function instead of yours. It would work fine.
void copy(char *s1,char *s2,char ch)
{
while(*s1!='\0')
{
if(*s1!=ch)
{
*s2=*s1;
s2++;
}
s1++;
}
*s2='\0';
}
U can ask more such..
OM NAMAH SHIVAY
Reply:/*
copy all characters from string1 into string2 except ch
method:
walks through each character in string1 using a pointer to
the characters, stopping at the C end-of-string char '\0', and
steps the pointer by the sizeof(char)
appends an end-of-string char to the output string2 after all valid characters have been copied.
NOTE BENE: output buffer (string2) must be sufficient to hold all characters of input buffer (string1). No checking is done to ensure this here.
*/
void str_copy_drop(const char *string1, char *string2, char ch) {
if (( 0 != string1 ) %26amp;%26amp; ( 0 != string2)) {
char* p1 = (char*)string1;
char* p2 = string2;
while ( (*p1) != '\0' ) {
if ( (*p1) != ch ) {
(*p2) = (*p1);
p2 += sizeof(char);
}
p1 += sizeof(char);
}
(*p2) = '\0';
}
}
You'll have to format the indentation yourself, as yA doesn't allow tabs.
Reply:you would have to go through the string, character by character and compare it with the parameter ch. if it matches then dont copy it to the new string. you need to know the length of the string so you know how many characters to compare.
pseudocode:
set 2 counters to 0
get length of string
loop "length of string" times
if string1[couter1] = !ch
copy string1[counter1] to string2[counter2]
increment counter2
loop until at end of string1
just a note (going by your function declaration), the file should be opened outside of the routine and read. then pass the pointer to the string. you dont need the "char s1, s2 pointers since you are passing the string pointers to the function (which you are not using by the way).
which copies the string string1 to string2 but with all occurrences of the character
passed as parameter ch omitted.
HERE IS WHAT I HAVE TRIED: its funny but can you check it and write me a correct program..
#include%26lt;stdio.h%26gt;
#include%26lt;string.h%26gt;
void str_copy_drop(const char *string1, char *string2, char ch);
void str_copy_drop(const char *string1, char *string2, char ch)
{
char *s1[20],*s2[20];
FILE *input;
input =fopen("string.txt","r");
fscanf(input,"%s",%26amp;s1);
s2= strcpy(s2,s1);
printf("\ncopied string is %s\n",s2);
}
above programs is wrong...i need solution for question described above..
Many thanks!!
Problem on C program(strings)...please try to solve.?
Use this function instead of yours. It would work fine.
void copy(char *s1,char *s2,char ch)
{
while(*s1!='\0')
{
if(*s1!=ch)
{
*s2=*s1;
s2++;
}
s1++;
}
*s2='\0';
}
U can ask more such..
OM NAMAH SHIVAY
Reply:/*
copy all characters from string1 into string2 except ch
method:
walks through each character in string1 using a pointer to
the characters, stopping at the C end-of-string char '\0', and
steps the pointer by the sizeof(char)
appends an end-of-string char to the output string2 after all valid characters have been copied.
NOTE BENE: output buffer (string2) must be sufficient to hold all characters of input buffer (string1). No checking is done to ensure this here.
*/
void str_copy_drop(const char *string1, char *string2, char ch) {
if (( 0 != string1 ) %26amp;%26amp; ( 0 != string2)) {
char* p1 = (char*)string1;
char* p2 = string2;
while ( (*p1) != '\0' ) {
if ( (*p1) != ch ) {
(*p2) = (*p1);
p2 += sizeof(char);
}
p1 += sizeof(char);
}
(*p2) = '\0';
}
}
You'll have to format the indentation yourself, as yA doesn't allow tabs.
Reply:you would have to go through the string, character by character and compare it with the parameter ch. if it matches then dont copy it to the new string. you need to know the length of the string so you know how many characters to compare.
pseudocode:
set 2 counters to 0
get length of string
loop "length of string" times
if string1[couter1] = !ch
copy string1[counter1] to string2[counter2]
increment counter2
loop until at end of string1
just a note (going by your function declaration), the file should be opened outside of the routine and read. then pass the pointer to the string. you dont need the "char s1, s2 pointers since you are passing the string pointers to the function (which you are not using by the way).
Question abot C program?
we write a program in a compilar %26amp; save it .c ,how does the compilar convert it in .exe file where r these exe files saved.
please provide me with complete detail im new to programing
Question abot C program?
The location of the exe depents of the compiler.
What compiler do you use?
please provide me with complete detail im new to programing
Question abot C program?
The location of the exe depents of the compiler.
What compiler do you use?
Write a C program to print the powers from 1 to n of a given integer m.?
Write a C program to print the powers from 1 to n of a given integer m. Your program must keep finding and printing the powers until a negative value is entered for m. You have to use a nested loop – the outer loop has to be a sentinel-controlled loop(sentinel value of %26lt;0) , the inner loop is a counter controlled loop that is executed n times ! Eg: Enter a number m = 2 Powers up to n = 4 The powers of 2 are : 1 2 4 8
Write a C program to print the powers from 1 to n of a given integer m.?
#include %26lt;stdio.h%26gt;
#include %26lt;math.h%26gt;
int main()
{
int m = 2;
int n = 4;
int i = 0;
int res = 0;
for (i = 0; i %26lt; n; i++)
{
res = pow(m, i);
printf("%d ", res);
}
}
Reply:If the powers are supposed to be from "1" to n, answer for m=2 and n=4 will be 2, 4, 8, 16. For answer to be 1 2 4 8, powers should be from "0" to "n-1"
-----------------------------
#include %26lt;stdio.h%26gt;
int main()
{
int m = 0;
int n = 0;
printf( "Enter value of m: ") ;
scanf( "%d", m ) ;
printf( "Enter value of n: ") ;
scanf( "%d", n ) ;
long pwr = 1;
for( int i = 1; i %26lt;= n; i++ )
printf("%d^%d = %d\n", m, i, pwr*n);
return 0;
}
deliver flowers
Write a C program to print the powers from 1 to n of a given integer m.?
#include %26lt;stdio.h%26gt;
#include %26lt;math.h%26gt;
int main()
{
int m = 2;
int n = 4;
int i = 0;
int res = 0;
for (i = 0; i %26lt; n; i++)
{
res = pow(m, i);
printf("%d ", res);
}
}
Reply:If the powers are supposed to be from "1" to n, answer for m=2 and n=4 will be 2, 4, 8, 16. For answer to be 1 2 4 8, powers should be from "0" to "n-1"
-----------------------------
#include %26lt;stdio.h%26gt;
int main()
{
int m = 0;
int n = 0;
printf( "Enter value of m: ") ;
scanf( "%d", m ) ;
printf( "Enter value of n: ") ;
scanf( "%d", n ) ;
long pwr = 1;
for( int i = 1; i %26lt;= n; i++ )
printf("%d^%d = %d\n", m, i, pwr*n);
return 0;
}
deliver flowers
Help With My C++ Program PLEASE?
This is what I have now and I have 2 have to write a program the reads students grades together with their test grades. It suppose to compute the average test scores an then assign the appropriate grade. have to use a void function to determine the average for the five test scores and a value returning function to determine and return each students grade. the students grades are on an infile and i have to output it to an outfile.
#include %26lt;iostream%26gt;
#include %26lt;fstream%26gt;
using namespace std;
calculateGrade (float,average);
int main ()
{
ifstream infile;
infile.open("C:\inGrade.dat");
outfile %26lt;%26lt; calculateGrade%26lt;%26lt; endl;
ofstream outfile;
outfile.open("C:\FinalGrades.txt");
infile.close ();
outfile.close ();
system("pause");
return 0;
char calculateGrade (float average)
{
char grade;
if (average %26gt;= 80.0)
grade = 'A';
else if (average %26gt;= 70.0)
grade = 'B';
else if (average %26gt;= 60.0)
grade = 'C';
else if (average %26gt;= 50.0)
grade = 'D';
else
grade = 'F';
return (grade);
}
}
Help With My C++ Program PLEASE?
In your function prototype line, you need to define the return type, or you will get an error saying that two functions differ only in their return type. Also you have a comma between void and average. Get rid of it.
Also, when you call calculateGrade, you need to pass the argument.
I am not going to finish the program for you, but this should be enough to help you make some progress.
Reply:Why is calculateGrade inside main? Also you're using outfile before defining it.
"outfile %26lt;%26lt; calculateGrade%26lt;%26lt; endl;
ofstream outfile;
outfile.open("C:\FinalGrades.t... "
When calling calculateGrade() you're not using the correct syntax or arguments..
"outfile %26lt;%26lt; calculateGrade%26lt;%26lt; endl;"
When declaring calculateGrade you have a comma after the type 'float'
"calculateGrade (float,average);"
I recommend you pay more attention to the compiler error output as it will probably tell you most of that.
Reply:Ok, what exactly did you need help with in this program?
#include %26lt;iostream%26gt;
#include %26lt;fstream%26gt;
using namespace std;
calculateGrade (float,average);
int main ()
{
ifstream infile;
infile.open("C:\inGrade.dat");
outfile %26lt;%26lt; calculateGrade%26lt;%26lt; endl;
ofstream outfile;
outfile.open("C:\FinalGrades.txt");
infile.close ();
outfile.close ();
system("pause");
return 0;
char calculateGrade (float average)
{
char grade;
if (average %26gt;= 80.0)
grade = 'A';
else if (average %26gt;= 70.0)
grade = 'B';
else if (average %26gt;= 60.0)
grade = 'C';
else if (average %26gt;= 50.0)
grade = 'D';
else
grade = 'F';
return (grade);
}
}
Help With My C++ Program PLEASE?
In your function prototype line, you need to define the return type, or you will get an error saying that two functions differ only in their return type. Also you have a comma between void and average. Get rid of it.
Also, when you call calculateGrade, you need to pass the argument.
I am not going to finish the program for you, but this should be enough to help you make some progress.
Reply:Why is calculateGrade inside main? Also you're using outfile before defining it.
"outfile %26lt;%26lt; calculateGrade%26lt;%26lt; endl;
ofstream outfile;
outfile.open("C:\FinalGrades.t... "
When calling calculateGrade() you're not using the correct syntax or arguments..
"outfile %26lt;%26lt; calculateGrade%26lt;%26lt; endl;"
When declaring calculateGrade you have a comma after the type 'float'
"calculateGrade (float,average);"
I recommend you pay more attention to the compiler error output as it will probably tell you most of that.
Reply:Ok, what exactly did you need help with in this program?
I did a funny C++ program...now what hahahahah?
hey guys my question is what do i do when i finish with my program hahahahah the teacher only tells us to send us the sorce code.
but i never know how do i send the program to other people so they can see my work.
and if i send them the progam will it conflict on there computer ? becouse they dont have the .NET update ?
how do i make a program in C++ and on visual basic so anyone can see it at the end i mean,
how do i convert it to an .EXE file ?
my main question is... what do i do next when i finish the program ?
I did a funny C++ program...now what hahahahah?
I use borland builder, Everytime I save the file, It also makes an .exe version of the file, check the folder where you save files, they might be there. If not you should look into Borland Turbo C++, it comes with a trial version and you can take all your programs ands make .exe files from them.
good luck!
Reply:I am not sure. Sorry. Report It
but i never know how do i send the program to other people so they can see my work.
and if i send them the progam will it conflict on there computer ? becouse they dont have the .NET update ?
how do i make a program in C++ and on visual basic so anyone can see it at the end i mean,
how do i convert it to an .EXE file ?
my main question is... what do i do next when i finish the program ?
I did a funny C++ program...now what hahahahah?
I use borland builder, Everytime I save the file, It also makes an .exe version of the file, check the folder where you save files, they might be there. If not you should look into Borland Turbo C++, it comes with a trial version and you can take all your programs ands make .exe files from them.
good luck!
Reply:I am not sure. Sorry. Report It
Friday, July 31, 2009
Were can i get a c++ program?
i need a website with a c++ program thats good
because i wanna program games
and found out that my program i use to program is the worst game programming system out there
so please help
Were can i get a c++ program?
You can get a c++program, then you can visit at http://expert.hyparoffice.com/
I think it's best site for c++ program.
Reply:i think you could buy microsoft visual studio -- its one of the best compilers ive worked with
Reply:Microsoft - free Platform SDK and DirectX updates
because i wanna program games
and found out that my program i use to program is the worst game programming system out there
so please help
Were can i get a c++ program?
You can get a c++program, then you can visit at http://expert.hyparoffice.com/
I think it's best site for c++ program.
Reply:i think you could buy microsoft visual studio -- its one of the best compilers ive worked with
Reply:Microsoft - free Platform SDK and DirectX updates
Subscribe to:
Posts (Atom)