the user input a string character how to promt him ro enter integer again
I have to inpu integer for c++ code how can i check whether the user input integer or a string character if ..
there are functions available in ctype.h header
isalph()
isalnum()
isdigit()
use them
Saturday, May 22, 2010
Write a c program to print the answer of a task which is given as a single string as a value?
for eg:- if we give 5+3 as an expression the output should be 8
that is sum of the given expression
not by reading each character into one variable.
the input should be into one single string
Write a c program to print the answer of a task which is given as a single string as a value?
Here are some links:
http://finance-old.bi.no/~bernt/gcc_prog
http://howstuffworks.com/c.htm
http://www.cs.cf.ac.uk/Dave/C/CE.html
that is sum of the given expression
not by reading each character into one variable.
the input should be into one single string
Write a c program to print the answer of a task which is given as a single string as a value?
Here are some links:
http://finance-old.bi.no/~bernt/gcc_prog
http://howstuffworks.com/c.htm
http://www.cs.cf.ac.uk/Dave/C/CE.html
Do u know, in c++ programming, how I can infile a string which has exactly n characters in it? I appreciate it
If you use fopen for the stream you could do an fread to read a specific number of bytes from the stream.
bridal flowers
bridal flowers
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.
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.
How to write C program for finding reverse of a string?
# include %26lt;conio.h%26gt;
# include %26lt;stdio.h%26gt;
# include %26lt;string.h%26gt;
void main()
{
char *str,*rev;
int n,i,cnt=0;
n=strlen(str);
printf ("Enter any string : ");
gets(str);
for (i=n; i%26lt;=0 ;i--)
{
rev[cnt]=str[i];
cnt++;
}
rev[cnt]='\0';
printf ("\n\nReverse string : %s",rev);
getch();
}
How to write C program for finding reverse of a string?
this sounds like homework, so I'll just give you an idea.
put the string in an array.
ie "string"
s[0] = 's'
s[1] = 't'
s[2] = 'r'
s[3] = 'i'
s[4] = 'n'
s[5] = 'g'
make a variable, say x, the size of the array. output the string backwards, starting from x while x %26gt;= 0.
5 - g
4 - n
3 - i
2 - r
1 - t
0 - s
# include %26lt;stdio.h%26gt;
# include %26lt;string.h%26gt;
void main()
{
char *str,*rev;
int n,i,cnt=0;
n=strlen(str);
printf ("Enter any string : ");
gets(str);
for (i=n; i%26lt;=0 ;i--)
{
rev[cnt]=str[i];
cnt++;
}
rev[cnt]='\0';
printf ("\n\nReverse string : %s",rev);
getch();
}
How to write C program for finding reverse of a string?
this sounds like homework, so I'll just give you an idea.
put the string in an array.
ie "string"
s[0] = 's'
s[1] = 't'
s[2] = 'r'
s[3] = 'i'
s[4] = 'n'
s[5] = 'g'
make a variable, say x, the size of the array. output the string backwards, starting from x while x %26gt;= 0.
5 - g
4 - n
3 - i
2 - r
1 - t
0 - s
Sunday, August 2, 2009
Write program in c which will which will read a string & rewrite it in the alphabetical order?
ask again in Computer software section .... not authors
Write program in c which will which will read a string %26amp; rewrite it in the alphabetical order?
What he said..then a bunch of if-then commands.
Write program in c which will which will read a string %26amp; rewrite it in the alphabetical order?
What he said..then a bunch of if-then commands.
Write a c++ program that convert numeric value to string?
for example:
input: 190.65
output:one hundred ninety and sixty five
Write a c++ program that convert numeric value to string?
Step 1: Convert floating point number to a string using these samples
http://www.cprogramming.com/tips/showTip...
http://www.codeguru.com/forum/showthread...
i.e., 190.65 to
convertedStr = "190.65";
Step 2: Have an array of strings like
text[0] = "";
text[1] = "one";
text[2] = "two";
text[3] = "three";
and lookup for each char in the converted string:
if(convertedStr[0] == '1') output = text[1];
wedding reception flowers
input: 190.65
output:one hundred ninety and sixty five
Write a c++ program that convert numeric value to string?
Step 1: Convert floating point number to a string using these samples
http://www.cprogramming.com/tips/showTip...
http://www.codeguru.com/forum/showthread...
i.e., 190.65 to
convertedStr = "190.65";
Step 2: Have an array of strings like
text[0] = "";
text[1] = "one";
text[2] = "two";
text[3] = "three";
and lookup for each char in the converted string:
if(convertedStr[0] == '1') output = text[1];
wedding reception flowers
Subscribe to:
Posts (Atom)