|
Basically I have two programs... the first program as you to input a total number of variables you want... max of 8.. then it ask you for its value... after it does all that it ask you if you want to add subtract mult or divide... then once all that is done it out puts to a file of your choice(what you name it)
LOOKS LIKE
a 1
b 2
c 3
d 4
e 5
f 6
g 8
h 10
add
a b
sub
d e
mul
e a
div
c d
and so on.... my problem is in my second program im trying to read the values in the being able to read in the command add sub div or mul... i attempt while(!fin.eof()) and read in the opperation add,sub and so on then the 2 variables like a b c d e f and so on... then run a bunch of if statesments to test if they match and once it does it outputs the answer.. the i want it to go to the next line...and read in next opperation and 2 variables and compute but it usually fails...
heres sample code...
#include <iostream>
#include <fstream>
#include <iomanip>
//dynamic memory
using namespace std;
int main()
{
ifstream fin;
ofstream fout;
char filename[20];
int pause,x,y,z;
int int1,int2,int3,int4,int5,int6,int7,int8;
char char1,char2,char3,char4,char5,char6,char7,char8;
string opp1[x];
char aa[x];
char bb[x];
x=0;
cout <<"Please enter the filename that you created to store"<<endl;
cout="" <<"information="" in="" the="" first="" program.="" ex:="" c:\data.txt"<<endl;
="" cin="">>filename;
fin.open(filename, ios::in);
cout<<"This is my awesome program:"<<endl;
if="" person="" doesnt="" enter="" all="" 8="" variables="" then="" they="" fill="" with="" zeros
="" int1="0;
" int2="0;
" int3="0;
" int4="0;
" int5="0;
" int6="0;
" int7="0;
" int8="0;
" char1="0;
" char2="0;
" char3="0;
" char4="0;
" char5="0;
" char6="0;
" char7="0;
" char8="0;
" fin="">> char1 >>int1;
fin >> char2 >>int2;
fin >> char3 >>int3;
fin >> char4 >>int4;
fin >> char5 >>int5;
fin >> char6 >>int6;
fin >> char7 >>int7;
fin >> char8 >>int8;
cout <<char1 <<"=" <<int1 <<endl;
cout <<char2 <<" =="" "="" <<int2="" <<endl;
="" cout="" <<char3="" <<int4="" <<char5="" <<int6="" <<char7="" <<int8=""
="" while(!="" fin.eof())
="" {
="" fin="">> opp1[x];
//cout <<opp1[x] <<endl;
="" fin="">>aa[x];
//cout <<aa[x]<<" ";
="" fin="">>bb[x];
//cout <
|
|
|
|
|
Hello,
i a little newbie to C++. So sorry for some stupid questions.
The following scenario:
We have a java application running on 200 pcs in a network enviroment. If a user starts the app the complete jre has to be loaded from a mounted network volume. This took about 20 to 40 sec. We cannot change this...
So currently i'm trying to write a splash screen which is showing the user that something is going on.
The splash screen is implemented. Now my question. Is there an easy way to lauch a jar as a process from c++ in that way that the splash screen waits until the java app is started?
Are ther tutorials in the web available?
Thanks for any help.
Regards,
Carsten
University of Konstanz
|
|
|
|
|
if you have a console command that can be launching your java app, you could so easily call
ShellExecute(NULL, "open", "myCommandLine here", NULL, NULL, SW_SHOWMINIMIZED);
or
system("myCommandLine here");
TOXCCT >>> GEII power [toxcct][VisualCalc]
-- modified at 5:46 Wednesday 2nd November, 2005
|
|
|
|
|
Hi,
to launch my java app this works... but how do i wait then with my c++ app until the app/process is really completed?
Thanks for any help.
Regards
Carsten
|
|
|
|
|
i'm not sure, but i think of deporting this code into a worker thread... see if you don't find some infos on the web on that subject.
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
|
Hi all,
I have a very important problem. that How to judge a string encoding is euc, sjis, ascii or others?
I must alway kown a string encoder, and I must convert it to other encoder.
so first, I must know the encoder of a string.
thank you very much.
thanks a lot.
---------------------------
Vc++.net Managed
|
|
|
|
|
a function that judge a string is ASCII or EUC, SJIS, JIS was welcome.
thanks.
----Junyin.Wu
|
|
|
|
|
there is no way to know such an information programatically... sorry
there is only one thing you can know : if the length of the string have an odd number of bytes, it cannot be UNICODE
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
try IMultiLanguage2::DetectCodepageInIStream
http://blog.joycode.com/jiangsheng
http://blog.csdn.net/jiangsheng
http://bloglines.com/public/jiangsheng
Command what is yours
Conquer what is not
---Kane
|
|
|
|
|
thank you very much,
and we are trying.....
|
|
|
|
|
Of course it can be Unicode with an odd number of bytes. In Unicode text encoded with UTF-8, the characters are composed of byte sequences of sizes between 1 and 4 bytes, depending on the character. Perhaps you meant UTF-16 or UTF-32?
--
The Blog: Bits and Pieces
-- modified at 1:40 Tuesday 1st November, 2005
|
|
|
|
|
|
Hi,
Being relatively new to socket programming, I need some assistance in sending and receiving data over a TCP connected socket. I'm familiar with using send and recv commands to send and recv buffered character data, but what about if I want to send and recv data formatted within a structure? For example,
<code>
main ()
{
struct {
int data1;
double data2;
bool indicator;
}msg;
// initialize data
msg.data1 = 0;
msg.data2 = 5.8;
msg.inidicator = false;
// send data
.....
// receive data
.....
}
</code>
Are the send and recv commands the right ones to use for this type of information to send and receive data over a TCP connected socket or are there other commands that are better suited for this. When I use the send(socketfd, (char *)&msg, 0), it "appears" to work, but when receiving the data using recv(socketfd, (char *)&msg, 0), it returns with a -1.
Thanks in advance for any help.
-Martin
NB: The commands must work on both the Windows and UNIX side, so Windows specific commands wouldn't work.
|
|
|
|
|
you are sending 0 bytes. you need to give it a size that your are sending. You also need to give a size when you recv.
It would work best if you just used sizeof(msg)
|
|
|
|
|
just check out the following code:
<br />
main()<br />
{<br />
int a=32;<br />
int b=0x20;<br />
printf("%d %d",a,b);<br />
getch();<br />
}<br />
the o/p of this code as expected would be -->32 32 now my question is that if i want the o/p to be like this-->32 0x20 what should i do.i am open to suggestions in C++ also.
plz ans asap.
thank you.
bye
That is a good way of doing difficult thing easily sir but i dont want to use specifier. i want to use the method of sepration which is used by compiler itself. try to differentiate between the two using functions atoi()
and itoa().
however thank you for your time sir and plz pardon me for my english
amsbali@yahoo.co.in
-- modified at 7:49 Sunday 30th October, 2005
|
|
|
|
|
just change your format string :
printf("%d %#X", a, b);
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
that is a good way of doing difficult thing easily sir but i dont want to use specifier. i want to use the method of sepration which is used by compiler itself. try to differentiate between the two using functions atoi()
and itoa().
however thank you for your time sir and plz pardon me for my english
|
|
|
|
|
two things :
1) you never said you didn't wan't the way i gave you
2) you say you solved it, but you don't give any feedback here on how you did it...
i'm curious to know how, because i don't really see how this is possible (or i did not understood the question).
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
What seems to be the problem here is that you don't realize what compile-time and run-time means. What you are trying to accomplish is as far as I know impossible. Once the compiler parses the line int b=0x20; it automatically defines a symbol in the data stack and initializes that space with the value of 0x20, which in base 10 is 32. The compiler however does not store any base information along with the value. Hence, the problem you are posing is unrealistig to say the least. Maybe I don't understand your question, but it really seems to me that you aren't really asking the right question.
Note that most answers are found by simply asking the right question!
I'm waiting for more information on the subject!
(also, as a note -- I think this is a post that doesn't necessarily belong in the C++/CLI area)
|
|
|
|
|
i have an app in c++ and i need to send an e-mail when certain conditions occurs, i´ve found many source code but is for c# and .net.
Pls anybody help me.
Thanks.
|
|
|
|
|
Check out http://www.codeproject.com/internet/csmtpconn.asp or the updated version at http://www.naughter.com/smtp.html
Brad Bruce
|
|
|
|
|
Ok, i have tried a few other sites, but have yet to get a response and i'm getting really nervous...
Tomorrow I have a C++ test in my grade 11 computer science course and my teacher gave us a few problems to do/practise at home. (Note we use Visual C++ from Visual Studio 6.0)
Problem 1. Have the user input a 4-digit character array or string. Have your program convert this string into an integer value without using the atoi function.
As it clearly states, i cannot use the atoi function. Now a previous question wanted the opposite (integer to char array) with itoa function and i got that working with the code i have in the txt file.
Problem 2. Have the user guess at random number. Have the computer tell the user either “Higher” or “Lower” until correct. The program will show the total number of guesses. Also, if the user is a moron, tell them so. For example, assume the correct number is 12. If the user inputs 7 and your program informs the user “higher”, if at any later time the user inputs a number of 7 or lower, the program is permitted to call the user a “moron”.
My question is if someone can please help me by coding this, just so that i can review the code and be ready for the test tomorrow. I've missed the class the last 4 days with the flu and have fallin a little behind. Also, if you could code it at a similar level as the code in the txt file, i would really appriciate it because thats how far our class as gotten so far. Please refer to the text file.
PS: I know it may not be exactly whta you'd want to do, but i would really appriciate it and it would help me dramatically.
Link to the .txt file...
http://www.megaupload.com/?d=RU48CFTR
|
|
|
|
|
MarkoOkuka wrote: Problem 1. Have the user input a 4-digit character array or string. Have your program convert this string into an integer value without using the atoi function.
A string is just an array of chars. Each char has a numeric value. If you work out the char values for numbers, you can easily turn them into digits, left to right, and multiply by 10/100/1000.
With regard to the second problem, all you need to do is keep their last guess in a variable, and then if they were lower, and go lower again, you have everything you need to work that out. What have you done so far on this ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
possibly a dump question, but better be safe....
if I have a class like this:
<br />
class Foo<br />
{<br />
std::vector<Foo2> vectorWithFoo2; <br />
};<br />
and then allocate a pointer of Foo
Foo* pFoo = new Foo;
the pFoo is allocated in the heap, right?
Now, each time I push_back a Foo2 into the vector, is it stored in the stack or the heap? I think its the heap but I wanted to be sure...
|
|
|
|