switch( temp1[0] )
{
case 'c':
case 'C':
Processcrecord( temp1, prnfile, validdata );
break;
case 'i':
case 'I':
case 'r':
case 'R':
ProcessIRecord( temp1, prnfile, validdata );
break;
case 'd':
case 'D':
processdrecord( temp1, prnfile, validdata );
break;
default: prnfile<< "Unknown record\n";
prnfile<< temp1 << endl;
};
if(Processcrecord( temp1, prnfile, validdata )){ true; }{
validdata << temp1 << endl;// suppose to check that the function evaluates true
break;// and then writes it to the validdata file.
}
if(ProcessIRecord( temp1, prnfile, validdata )){ true; }{
validdata << temp1 << endl;
break;
}
if(processdrecord( temp1, prnfile, validdata )){ true; }{
validdata << temp1 << endl;
break;
}
does //if(Processcrecord( temp1 etc ) actually perform the task its suppose to?
Is the code correct or does the if statement always return true regardless? 2 2247
muser wrote: switch( temp1[0] ) { case 'c': case 'C': Processcrecord( temp1, prnfile, validdata ); break;
case 'i': case 'I': case 'r': case 'R': ProcessIRecord( temp1, prnfile, validdata ); break;
case 'd': case 'D': processdrecord( temp1, prnfile, validdata ); break; default: prnfile<< "Unknown record\n"; prnfile<< temp1 << endl; };
if(Processcrecord( temp1, prnfile, validdata )){ true; }{ validdata << temp1 << endl;// suppose to check that the function evaluates true break;// and then writes it to the validdata file. } if(ProcessIRecord( temp1, prnfile, validdata )){ true; }{ validdata << temp1 << endl; break; } if(processdrecord( temp1, prnfile, validdata )){ true; }{ validdata << temp1 << endl; break; } does //if(Processcrecord( temp1 etc ) actually perform the task its suppose to?
I don't know. It doesn't seem to make sense. If the condition between
the braces of the if() is true (i.e. if Processcrecord returns
something that evaluates to true), the following code block is
executed. That code block only contains true; which is a statement that
actually doesn't do anything and has (of course) true as result. That
result is discarded. So the whole if() is useless. The code block
following the { true; } one is executed unconditionally. So your:
if(Processcrecord( temp1, prnfile, validdata )){ true; }{
validdata << temp1 << endl;
break;
}
does the same as:
Processcrecord( temp1, prnfile, validdata );
validdata << temp1 << endl;
break;
And btw, what is the break supposed to do? Or is that if() actually
supposed to be within the switch/case?
Is the code correct or does the if statement always return true regardless?
An if statement doesn't return anything.
muser wrote: switch( temp1[0] ) { case 'c': case 'C': Processcrecord( temp1, prnfile, validdata ); break;
Study the std::tolower and std::toupper functions:
swtich(std::tolower(temp1[0]))
{
case 'c': case 'i': case 'I': case 'r': case 'R': ProcessIRecord( temp1, prnfile, validdata ); break;
case 'd': case 'D': processdrecord( temp1, prnfile, validdata ); break; default: prnfile<< "Unknown record\n"; prnfile<< temp1 << endl; };
does //if(Processcrecord( temp1 etc ) actually perform the task its
suppose to? Is the code correct or does the if statement always return true regardless?
I suggest you use a different naming convention.
At first look, all the functions looked the same or
the others look like a misspelling of the first.
--
Thomas Matthews
C++ newsgroup welcome message: http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq: http://www.raos.demon.uk/acllc-c++/faq.html
Other sites: http://www.josuttis.com -- C++ STL Library book This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: domeceo |
last post by:
can anyone tell me why I cannot pass values in a setTimeout function
whenever I use this function it says "menu is undefined" after th
alert.
function imgOff(menu, num) {
if (document.images) {...
|
by: Randell D. |
last post by:
Folks,
I'm sure this can be done legally, and not thru tricks of the trade - I
hope someone can help.
I'm writing a 'tool' (a function) which can be used generically in any
of my projects. ...
|
by: laredotornado |
last post by:
Hello, I am looking for a cross-browser way (Firefox 1+, IE 5.5+) to
have my Javascript function execute from the BODY's "onload" method,
but if there is already an onload method defined, I would...
|
by: bluejack |
last post by:
Ahoy... before I go off scouring particular platforms for specialized
answers, I thought I would see if there is a portable C answer to this
question:
I want a function pointer that, when...
|
by: Larax |
last post by:
Best explanation of my question will be an example, look below at this
simple function:
function SetEventHandler(element)
{
// some operations on element
element.onclick =
function(event)
{
|
by: VK |
last post by:
I was getting this effect N times but each time I was in rush to just
make it work, and later I coudn't recall anymore what was the original
state I was working around. This time I nailed the...
|
by: pbmods |
last post by:
AN INTRODUCTION TO FUNCTION OBJECTS
LEVEL: INTERMEDIATE
PREREQS: OBJECTS
You've seen it before. You're setting up an XMLHttpRequest call, and you need to execute a function when it returns, so...
|
by: RandomElle |
last post by:
Hi there
I'm hoping someone can help me out with the use of the Eval function. I am using Access2003 under WinXP Pro. I can successfully use the Eval function and get it to call any function with...
|
by: Bryan Parkoff |
last post by:
I write my large project in C++ source code. My C++ source code
contains approximate four thousand small functions. Most of them are
inline. I define variables and functions in the global scope....
|
by: Oltmans |
last post by:
Hi all,
I'm stuck in a situation where I need help. Any help will be highly
appreciated. I've created an object, after creating the object, I'm
assigning one of its functions to an event handler...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |