|
Well, did you add DriverWork.cpp to your solution?
Well, I was experienced problem like you. Cause of error is that I include header file using #include keyword but know added header and source file to my solutions. Whenever I've added it to my solutions, error disappeared.

|
|
|
|
|
|
The below is GList.H
#ifndef __GLIST_H
#define __GLIST_H
#include <assert.h>
#include <STDIO.H>
#include <STDLIB.H>
#include <STRING.H>
#include <STRNG.H>
#include <MALLOC.H>
typedef enum bool { false, true};
class GList
{
private:
char **arr;
int length;
void FillEmptyAll(int);
void ResizeList(int);
void SetArr(char **);
void SetLen(size_t);
char **GetArr() { return arr; }
public:
size_t GetLen();
void Add(const char*);
void Add(String);
void SetValue(size_t, const char*);
void SetValue(size_t, String);
char* GetValue(size_t);
void InsertValue(size_t, const char*);
void InsertValue(size_t, String);
void FillEmptyRange(size_t, size_t);
void CreateMemList(size_t);
void RemoveAt(size_t);
void RemoveRange(size_t, size_t);
void RemoveValue(const char *);
void RemoveValue(String);
void RemoveAllValue(const char *);
void RemoveAllValue(String);
GList();
GList(const GList& L); GList& operator=(const GList& L); virtual ~GList();
};
inline GList::GList(void)
{
length = 1;
arr = (char**) malloc(sizeof(char*) * length);
}
inline GList::GList(const GList& L): length(L.length),
arr((char**)malloc(sizeof(char*) * L.length))
{
int idx = L.length - 1;
for(int i = 0; i < idx; i++){
*(arr + i) = *(L.arr + i);
}
*(arr + idx) = 0;
}
inline GList& GList::operator=(const GList& L)
{
if (this == &L) return *this;
else
{
length = L.length;
if (arr != 0)
{
free(arr);
arr = 0;
}
arr = (char**)malloc(sizeof(char*) * L.length);
int idx = L.length - 1;
for(int i = 0; i < idx; i++)
*(arr + i) = *(L.arr + i);
*(arr + idx) = 0;
}
return *this;
}
inline GList::~GList()
{
if (arr != 0)
{
free(arr);
}
printf("Destructor GList");
}
void GList::FillEmptyAll(int len)
{
for(int i = 0; i < len; i++)
*(arr + i) = strdup("");
*(arr + len) = 0;
}
void GList::FillEmptyRange(size_t startAt, size_t startEnd)
{
if (startEnd - startAt <= 0) return;
for(int i = startAt; i < startEnd; i++)
SetValue(i, "");
}
void GList::CreateMemList(size_t numData)
{
if (numData == 0 || numData == 1)
{
length = 1;
if (arr != 0)
free(arr);
arr = (char**) malloc(sizeof(char*) * length);
}
else
{
length = numData;
if (arr != 0)
{
free(arr);
arr = 0;
}
arr = (char**) malloc(sizeof(char*) * length);
if (arr == 0)
{
printf("Create new memory for List failed! Not enough memory");
abort();
}
FillEmptyAll(length - 1);
}
}
size_t GList::GetLen(void)
{
if (length == 0)
return 0;
return length-1;
}
void GList::SetValue(size_t index, const char *value)
{
if (index >= GetLen())
return;
else
*(arr + index) = strdup(value);
}
void GList::SetValue(size_t index, String value)
{
char *string = strdup(value);
SetValue(index, string);
if (string != NULL)
delete string;
}
void GList::SetLen(size_t newlength)
{
if (newlength <= 1)
length = 1;
length = newlength;
}
void GList::SetArr(char **array)
{
arr = array;
}
char* GList::GetValue(size_t index)
{
if (index >= GetLen() || index < 0)
return NULL;
else
return *(arr + index);
}
void GList::InsertValue(size_t index, const char *value)
{
char **newarr = 0;
int i;
int newLen = 0;
int idx = 0;
int oldLen = length - 1;
if (index > oldLen || index < 0)
return;
length = length + 1;
idx = length - 1;
newarr = (char**) malloc(sizeof(char*) * length);
if (newarr == 0)
{
printf("Insert new value to List failed! Not enought memory.");
abort();
}
for(i = 0; i < index; i++)
*(newarr + i) = *(arr + i);
for(i = idx - 1; i > index; i--)
*(newarr + i) = *(arr + (i-1));
*(newarr + index) = strdup(value);
assert(idx = length - 1);
*(newarr + idx) = 0;
if (arr != 0)
{
free(arr);
arr = 0;
}
arr = newarr;
newarr = 0;
if (newarr == 0)
delete newarr;
}
void GList::InsertValue(size_t index, String value)
{
char *str = strdup(value);
InsertValue(index, str);
if (str != NULL)
delete str;
}
void GList::Add(const char *value)
{
int idx = length - 1;
if (idx <= 0)
{
length = 2;
if (arr != 0)
{
free(arr);
arr = 0;
}
arr = (char**) malloc(sizeof(char*) * length);
if (arr == 0)
{
printf("Add new value to List failed!");
abort();
}
*(arr + 0) = strdup(value);
*(arr + (length -1)) = 0;
}
else if (idx >= 1)
{
length++;
char **newarr = 0;
newarr = (char**) malloc(sizeof(char*) * length);
if (newarr == 0)
{
printf("Add new value to List failed!\n");
abort();
}
for(int i = 0; i < idx; i++)
*(newarr + i) = *(arr + i);
*(newarr + idx++) = strdup(value);
assert(idx = length - 1);
*(newarr + idx) = 0;
if (arr != 0)
{
free(arr);
arr = 0;
}
arr = newarr;
newarr = 0;
if (newarr == 0)
delete newarr;
}
}
void GList::Add(String value)
{
char *str = strdup(value);
Add(str);
if (str != NULL)
delete str;
}
void GList::RemoveAt(size_t index)
{
int i, idx;
int len = length - 1;
idx = length - 1;
if (index >= len || idx == 0)
return;
for(i = index; i < idx - 1; i++)
{
*(arr + i) = *(arr + (i+1));
}
length = length - 1;
char **newarr;
newarr = (char**) malloc(sizeof(char*) * length);
if (newarr == NULL)
{
printf("Remove at index %i in List failed!", index);
abort();
}
idx = idx - 1;
for(i = 0; i < idx; i++)
*(newarr + i) = *(arr + i);
assert(idx = length - 1);
*(newarr + idx) = 0;
if (arr != 0)
{
free(arr);
arr = 0;
}
arr = newarr;
newarr = 0;
if (newarr == 0)
delete newarr;
}
void GList::RemoveRange(size_t startAt, size_t startEnd)
{
int oldLen = length - 1;
int numRemoveData = startEnd - startAt + 1;
int numMoveData = oldLen - numRemoveData - startAt;
int index = 0;
int lock = 0;
if ((numRemoveData < 0) || startEnd > oldLen -1)
return;
for(index = 0; index < numMoveData; index++)
*(arr + (index + startAt)) = *(arr + (startEnd + index + 1));
if (startEnd == oldLen - 1)
lock = startAt;
else if (startEnd < oldLen - 1)
lock = startAt + numMoveData;
length = length - numRemoveData;
if (length <= 1)
{
free(arr);
arr = 0;
length = 1;
}
else if (length > 1)
{
char** newarr= 0;
newarr = (char**) malloc(sizeof(char*) * length);
if (newarr == 0)
{
printf("Remove range %i to %i from List failed!",startAt, startEnd);
abort();
}
for(index = 0; index < lock; index++)
*(newarr + index) = *(arr + index);
assert(lock = length - 1);
*(newarr + lock) = 0;
if (arr != 0)
{
free(arr);
arr = 0;
}
arr = newarr;
newarr = 0;
if (newarr == 0)
delete newarr;
}
}
void GList::RemoveValue(const char *value)
{
int pos = 0;
int index = 0;
bool found = false;
int len = length - 1;
if ((value == NULL) || (len == 0)) return;
while ((index < len) && !found)
{
pos = strcmp(arr[index],value);
if (pos == 0)
found = true;
else
index++;
}
if (found)
RemoveAt(index);
}
void GList::RemoveValue(String value)
{
char *str = strdup(value);
RemoveValue(str);
if (str != NULL)
delete str;
}
void GList::RemoveAllValue(const char *string)
{
int index = 0;
int pos = 0;
if (string == NULL) return;
while (index < GetLen())
{
pos = strcmp(*(arr + index), string);
if (pos == 0)
RemoveAt(index);
else
index++;
}
}
void GList::RemoveAllValue(String string)
{
char *str = strdup(string);
RemoveAllValue(str);
if (str != NULL)
delete str;
}
#endif
/* -------------------------------------------------------------- */
/* INIClass.H */
/* Author : Nguyen Hong Phuc */
/* Copyright c 2013 */
/* -------------------------------------------------------------- */
#ifndef __INICLASS_H
#define __INICLASS_H
#include "HPCLASS.H"
#include <stdio.h>
#include <fcntl.h>
#include <sys\stat.h>
#include <io.h>
typedef enum ErrorCode {
Success = 0,
Invalid_PathFile = 1,
Invalid_Command = 2,
Invalid_Key = 4,
Invalid_Subkey = 6,
Invalid_CreateFile = 8,
Invalid_FileExisted = 10,
Invalid_FileName = 12,
Invalid_Parameters = 14,
Unknown_Error = 16
};
There is INIClass :
class INIClass : public GList
{
private:
GList fLines;
GList pList;
char *PathFileName;
char *cmdT;
ErrorCode error;
void InitStringProtocol();
void InitStringSystem();
int Initialize();
int CreateProtocol();
int CreateSystem();
int ReadFromFile();
int WriteToFile();
void CommandCreate(const char*);
public:
int Finaliaze();
//INIClass(char *[]);
INIClass(GList);
~INIClass();
};
inline INIClass::INIClass(GList mList)
{
error = Success;
PathFileName = "";
cmdT = "";
pList = mList;
pList.RemoveAt(0);
PathFileName = pList.GetValue(0);
pList.RemoveAt(0);
cmdT = pList.GetValue(0);
pList.RemoveAt(0);
//fLines.Add(" ");
//Initialize();
//fLines = NULL;
}
/* Deconstructor for INIClass */
inline INIClass::~INIClass(void)
{
//delete error;
//delete cmdT;
//delete PathFileName;
printf("\nDestructor INIClass.\n");
}
/* ------------- Define Property and Function for INIClass ----------------- */
int INIClass::Finaliaze(void)
{
int exit_code = 0;
return exit_code = Initialize();
}
int INIClass::Initialize()
{
int iType = -1;
char *cmdType[] = {"create", "remove", "read", "write", "edit"};
for(int i = 0; i < sizeof(cmdType) / sizeof(cmdType[0]); i++)
{
if (strcmp(cmdType[i], Trim(cmdT)) == 0)
{
iType = i;
break;
}
}
switch (iType)
{
case 0: //create
if (pList.GetLen() == 0)
error = Invalid_Parameters;
else
{
printf("Command Create is call.");
CommandCreate(pList.GetValue(0));
}
break;
default:
error = Invalid_Parameters;
break;
}
return error;
}
/* Initilize for Protocol */
void INIClass::InitStringProtocol()
{
fLines.Add("; Protocol.ini auto generated by NETCFG - File created by Hong Phuc");
fLines.Add("; ONLY SUPPORT FOR MYSELF, IF NEED TO USE PLEASE RE-EDIT");
fLines.Add("; PLEASE DO NOT REMOVE ANY LINE BELOW");
fLines.Add("[network.setup]");
fLines.Add("version=0x3110");
fLines.Add("netcard=hp2$nic,1,HP2$NIC,1");
fLines.Add("transport=hp2$ndishlp,HP2$NDISHLP");
fLines.Add("transport=hp2$netbeui,HP2$NETBEUI");
fLines.Add("lana0=hp2$nic,1,hp2$netbeui");
fLines.Add("lana1=hp2$nic,1,hp2$ndishlp");
//fLines.Add("\n");
fLines.Add("[HP2$NETBEUI]");
fLines.Add("NCBS=8");
fLines.Add("SESSIONS=3");
fLines.Add("DRIVERNAME=netbeui$");
fLines.Add("BINDINGS=HP2$NIC");
fLines.Add("LANABASE=0");
//fLines.Add("\n");
fLines.Add("[PROTMAN]");
fLines.Add("DriverName=PROTMAN$");
fLines.Add("PRIORITY=PKTDRV$");
//fLines.Add("\n");
fLines.Add("[PKTDRV]");
fLines.Add("DriverName=PKTDRV$");
fLines.Add("BINDINGS=HP2$NIC");
fLines.Add("intvec=0x60");
fLines.Add("chainvec=0x66");
//fLines.Add("\n");
fLines.Add("[HP2$NDISHLP]");
fLines.Add("DriverName=ndishlp$");
fLines.Add("BINDINGS=HP2$NIC");
//fLines.Add("\n");
fLines.Add("[HP2$NIC]");
}
/* Initialize for System */
void INIClass::InitStringSystem()
{
fLines.Add("; System.ini auto generated by NETCFG - File created by Hong Phuc");
fLines.Add("; ONLY SUPPORT FOR MYSELF, IF NEED TO USE PLEASE RE-EDIT.");
fLines.Add("; PLEASE DO NOT REMOVE ANY LINE BELOW");
fLines.Add("[386enh]");
fLines.Add("TimerCriticalSection=5000");
fLines.Add("UniqueDosPSP=TRUE");
fLines.Add("PSPIncrement=2");
//fLines.Add("\n");
fLines.Add("[network]");
fLines.Add("filesharing=no");
fLines.Add("printsharing=no");
fLines.Add("autologon=no");
fLines.Add("reconnect=yes");
fLines.Add("dospophotkey=N");
fLines.Add("lmlogon=<edit_by_netcfg>");
fLines.Add("preferredredir=<edit_by_netcfg>");
fLines.Add("autostart=<edit_by_netcfg>");
fLines.Add("maxconnections=8");
fLines.Add("sizworkbuff=1498");
//fLines.Add("\n");
fLines.Add("username=<edit_by_netcfg>");
fLines.Add("workgroup=<edit_by_netcfg>");
fLines.Add("computername=<edit_by_netcfg>");
fLines.Add("lanroot=<edit_by_netcfg>");
//fLines.Add("\n");
fLines.Add("[network drivers]");
fLines.Add("LoadRMDrivers=yes");
fLines.Add("transport=<edit_by_netcfg>");
fLines.Add("netcard=<edit_by_netcfg>");
fLines.Add("devdir=<edit_by_netcfg>");
}
//This function is create the Protocol.ini file
int INIClass::CreateProtocol(void)
{
printf("Creating Protocol.");
if (!Contains(PathFileName, "\\protocol.ini"))
{
if (!EndWith(PathFileName, "\\"))
PathFileName = strcat(PathFileName, "\\protocol.ini");
else
PathFileName = strcat(PathFileName, "protocol.ini");
}
if (FileExist(PathFileName))
error = Invalid_FileExisted;
else
{
InitStringProtocol();
error = WriteToFile();
}
return error;
}
//This function is create the System.ini file
int INIClass::CreateSystem(void)
{
//string strPathFile = PathFile;
if (!Contains(PathFileName, "\\system.ini"))
{
if (!EndWith(PathFileName, "\\"))
PathFileName = strcat(PathFileName, "\\system.ini");
else
PathFileName = strcat(PathFileName, "system.ini");
}
if (FileExist(PathFileName))
error = Invalid_FileExisted;
else
{
InitStringSystem();
error = WriteToFile();
}
return error;
}
int INIClass::ReadFromFile()
{
FILE *fname;
char data[256];
fname = fopen(PathFileName, "r");
if (fname != NULL)
{
while (!feof(fname))
{
fgets(data, 256, fname);
fLines.Add(Trim(data));
}
fclose(fname);
error = Success;
}
else
error = Invalid_PathFile;
return error;
}
int INIClass::WriteToFile()
{
FILE *stream;
printf("WTF call, PathFile = %s\n",PathFileName);
if (FileExist(PathFileName))
{
if (remove(PathFileName) == -1)
return error = Invalid_FileName;
}
stream = fopen(PathFileName, "wt");
if (stream != NULL)
{
for (int i = 0; i < fLines.GetLen(); i++)
{
char *value = fLines.GetValue(i);;
//write(handle, value, strlen(value));
fprintf(stream, value);
fprintf(stream, "\n");
}
fclose(stream);
error = Success;
}
else
error = Invalid_PathFile;
return error;
}
//This function is create an Protocol.ini/System.ini. Return : 0 - success
void INIClass::CommandCreate(const char *strType)
{
int iType = -1;
char *ctype[] = {"pro", "protocol", "sys", "system"};
for(int i = 0; i < sizeof(ctype) / sizeof(ctype[0]); i++)
{
if (strcmp(ctype[i], Trim(strType)) == 0)
{
iType = i;
break;
}
}
switch (iType)
{
case 0:
case 1:
printf("Create Protocol");
error = CreateProtocol();
break;
case 2:
case 3:
error = CreateSystem();
break;
default:
error = Invalid_Command;
break;
}
}
/* ----------------- End of INIClass --------------- */
#endif
#include <iniclass.h>
#include <hpclass.h>
#include <stdio.h>
#include <conio.h>
void main(int argc, char* argv[])
{
//clrscr();
int exit = 0;
GList mList(Split(argv));
INIClass ini(mList);
exit = ini.Finaliaze();
printf("\nEnd program - Exit code : %i",exit);
//delete ini;
}
When Compile and Run with arguments :
c:\Testini.exe c:\obj create protocol
The file c:\obj\protocol.ini is created but Null pointer assignments is display. I don't know why.
|
|
|
|
|
First of all, please remember the debugging 101:
1. Attach a debugger and try to run it then.
2. The debugger will stop at the Null Pointer assignement, and you can fix the error.
About Null pointer assignments:
Null pointer assignments occur when you try to access a pointer which's memory was deleted or not initialized (via malloc or new) and are a strong hint towards dangling and insecure pointers.
People becoming wiser in order to notice the stupid things they did back in the young days. This doesn't mean that they really stop doing those things. Wise people still do stupid things, only on purpose.
|
|
|
|
|
how can I draw real-time curve in coordinate system? The development compiler of mine is qt!thank you!
|
|
|
|
|
|
thank you ,but i can't find a good example for my application 
|
|
|
|
|
The first link is a Youtube video that shows how.
Veni, vidi, abiit domum
|
|
|
|
|
thank you for your tips ,but those can't solve the problem of real-time performance in my application!
|
|
|
|
|
What do you mean by "real-time performance"? If you expect that in Windows you are going to be disappointed. And drawing lines in Windows is exactly the same wherever the data comes from.
Veni, vidi, abiit domum
|
|
|
|
|
|
http://qt-project.org/forums/viewthread/14819[^]
People becoming wiser in order to notice the stupid things they did back in the young days. This doesn't mean that they really stop doing those things. Wise people still do stupid things, only on purpose.
|
|
|
|
|
thank you ,your advances would be good for me!
|
|
|
|
|
Hello!
I had an error in my project created with QT and C++
I created Server which gets data from AudioInput and gives it to UDP Socket, there is no problem, but in Client's project I had a problem, when I tried to write data to AudioOutput device after UDP Socket gets this data from net
in my project error was in this line "int l = audioSource->read(audioBuffer,input);" in
"qaudiooutput_win32_p.cpp"
and this is Call Stack at time debugging which shows this
QtMultimediad4.dll!QAudioOutputPrivate::deviceReady() Line 579 + 0x1c bytes C++
QtMultimediad4.dll!QAudioOutputPrivate::qt_static_metacall(QObject * _o=0x00b53308, QMetaObject::Call _c=InvokeMetaMethod, int _id=1, void * * _a=0x00b51d20) Line 52 + 0x8 bytes C++
what I did wrong
PLEASE HELP!!!!! 
|
|
|
|
|
|
Could be that the audio device is being locked up by the other caller. You don't show the actual error code but the function where it stalls out would indicate that he's checking if the device is ready.
You should post the actual error output instead of the call stack. Also, this is likely a problem with how you're using Qt, so you may be better off asking for help in a Qt forum.
|
|
|
|
|
Could anyone please help me to find why call to sort() is crashing at run-time in following code block:
string s = "Annnitttesrrh.";
vector<char> vecChar(s.begin(), s.end());
sort(vecChar.begin(), vecChar.end(), greater_equal<char>());
Am i missing something very basic ?
|
|
|
|
|
Kumar Anitesh wrote: Am i missing something very basic ? Not that I can figure out. I tried the same code, but using greater as the predicate and it works fine. This needs an STL expert to look at it, but you posted in the managed C++ forum; try http://www.codeproject.com/Forums/4486/ATL-WTL-STL.aspx[^].
Veni, vidi, abiit domum
|
|
|
|
|
Hello,
I'm a bit confused about the difference between:
LRESULT CALLBACK WndProc(HWND hWindow, UINT msg, WPARAM wParam, LPARAM lParam);
and
virtual void WndProc(Message %m);
I know that the first is to get message to menage event in win32, but so "WndProc(Message %m)" is the same thing when we are programming a Windows Form project?
The last question is: when is better to use NativeWindow methos and when is better to use win32 methods to menage events?
My project is a simple window form with a panel, on the Panel i call a window where I can menage OpenGL operations.
Could someone help me?
Thank you
|
|
|
|
|
The first version is the native unmanaged code version, and the second is the managed one[^]. As to which is better, that depends on the design and structure of your program.
Veni, vidi, abiit domum
|
|
|
|
|
Use a native window when you're working with native C/C++/WinAPI code and use the managed version when you're using managed code. Only reason to use native code when you have a managed project is if the managed version doesn't do something you need already (which is hardly ever the case).
|
|
|
|
|
Ok I need some help here. I have been through the MSDN sites and tried multiple types of sockets and streams.
What I am trying to do is this. I have a C++/CLI forms app using /clrsafe runtime.
What I need is socket so I can send a string like "^0!NO\r" through a raw TCP port. There is only a "one way connection here" the response will have to be on a listener stream but the system will not be making a socket connection with the program. I have completed this in Python script so those who know python this is how I did it.
Chost = '169.254.232.50'
Cport = 1555
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print 'Socket Created'
cam = socket.socket()
try:
s.bind((host, port))
except socket.error , msg:
print 'Bind failed. Error Code : ' +str(msg[0]) + ' Message ' + msg[1]
sys.exit()
Any help would be great,
|
|
|
|
|
The code is much the same as you have above, although you would use connect rather than bind ; see this tutorial[^].
Veni, vidi, abiit domum
|
|
|
|
|
Hi, I actually have 2 problems. If i enter gcgc, it should give me 4 when counting G's and C's but it gives me 3 instead. Also, the program doesn't stop by itself (I have to press control C to get out). What is wrong with my code?
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
char input = ' ';
int count = 0;
char newinput = ' ';
int newcount = 0;
cout << "Enter the DNA strand:";
cin >> input;
while (input != '\n')
{cin.get(input);
switch (toupper(input))
{
case 'C':
count++;
break;
case 'G':
count++;
break;}}
cout << "There are " << count << " C's and G's in this DNA strand."<< endl;
while (input != '\n')
{cin.get(input);
switch (toupper(input))
{
case 'B':
cout << "Invalid sequence! Please enter the correct nucleotide sequence:";
cin>>newinput;
cin.clear();
cin.ignore('\n');
break;
case 'D':
cout << "Invalid sequence! Please enter the correct nucleotide sequence:";
cin.clear();
cin.ignore('\n');
break;
case 'E':
cout << "Invalid sequence! Please enter the correct nucleotide sequence:";
cin.clear();
cin.ignore('\n');
break;
case 'F':
cout << "Invalid sequence! Please enter the correct nucleotide sequence:";
cin.clear();
cin.ignore('\n');
break;
case 'H':
cout << "Invalid sequence! Please enter the correct nucleotide sequence:";
cin.clear();
cin.ignore('\n');
break;
case 'I':
cout << "Invalid sequence! Please enter the correct nucleotide sequence:";
cin.clear();
cin.ignore('\n');
break;
case 'J':
cout << "Invalid sequence! Please enter the correct nucleotide sequence:";
cin.clear();
cin.ignore('\n');
break;
case 'K':
cout << "Invalid sequence! Please enter the correct nucleotide sequence:";
cin.clear();
cin.ignore('\n');
break;
case 'L':
cout << "Invalid sequence! Please enter the correct nucleotide sequence:";
cin.clear();
cin.ignore('\n');
break;
case 'M':
cout << "Invalid sequence! Please enter the correct nucleotide sequence:";
cin.clear();
cin.ignore('\n');
break;
case 'N':
cout << "Invalid sequence! Please enter the correct nucleotide sequence:";
cin.clear();
cin.ignore('\n');
break;
case 'O':
cout << "Invalid sequence! Please enter the correct nucleotide sequence:";
cin.clear();
cin.ignore('\n');
break;
case 'P':
cout << "Invalid sequence! Please enter the correct nucleotide sequence:";
cin.clear();
cin.ignore('\n');
break;
case 'Q':
cout << "Invalid sequence! Please enter the correct nucleotide sequence:";
cin.clear();
cin.ignore('\n');
break;
case 'R':
cout << "Invalid sequence! Please enter the correct nucleotide sequence:";
cin.clear();
cin.ignore('\n');
break;
case 'S':
cout << "Invalid sequence! Please enter the correct nucleotide sequence:";
cin.clear();
cin.ignore('\n');
break;
case 'U':
cout << "Invalid sequence! Please enter the correct nucleotide sequence:";
cin.clear();
cin.ignore('\n');
break;
case 'V':
cout << "Invalid sequence! Please enter the correct nucleotide sequence:";
cin.clear();
cin.ignore('\n');
break;
case 'W':
cout << "Invalid sequence! Please enter the correct nucleotide sequence:";
cin.clear();
cin.ignore('\n');
break;
case 'X':
cout << "Invalid sequence! Please enter the correct nucleotide sequence:";
cin.clear();
cin.ignore('\n');
break;
case 'Y':
cout << "Invalid sequence! Please enter the correct nucleotide sequence:";
cin.clear();
cin.ignore('\n');
break;
case 'Z':
cout << "Invalid sequence! Please enter the correct nucleotide sequence:";
cin.clear();
cin.ignore('\n');
break;
}
}
while (newinput != '\n')
{ cin.get(newinput);
switch (toupper(newinput))
{ case 'C':
newcount++;
break;
case 'G':
newcount++;
break;
}
}
cout << "There are " << newcount << " C's and G's in this DNA strand." << endl;
return 0;
}
|
|
|
|
|
You could simplify this by removing all those redundant case blocks and replaing them with a single default: . You could then use your debugger to find out why it does not break out of the loop.
Use the best guess
|
|
|
|
|