473,387 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Error - An unhandled win32 exception occured [472]

Hi all, I'm new to C programming. I'm running the code in Visual Studio where it will read a text file and after reading the file using struct. It will filter the data based on the if else condition below. I'm getting the "Error - An unhandled win32 exception occured [472]" and i think it should be something to do with the string "i".

I didn't post the other code but please let me know if you need it.

Sample of data file:
9001:0002:9003:0021:CLS
0001:0010:0003:0021:CLS


Expand|Select|Wrap|Line Numbers
  1. for (i = 0; i < count; i++){
  2. isValid = true;
  3. if (array[i].src < 1 || array[i].src > 1024){
  4. isValid = false;
  5. }
  6. else
  7. if (array[i].dest < 1 || array[i].dest > 1024){
  8. isValid = false;
  9. }
  10. else
  11. if (array[i].type < 1 || array[i].type > 10){
  12. isValid = false;
  13. }
  14. else
  15. if (array[i].port < 1 || array[i].port > 1024){
  16. isValid = false;
  17. }
  18. else
  19. if (strlen(array[i].data) < 1 || strlen(array[i].data) > 50)
  20. isValid = false;
  21.  
  22. //if meets the condition above writes to correct txt file
  23. if (isValid){
  24. n1++;
  25. fprintf(outFile, "%04d:%04d:%04d:%04d %s \n",
  26.     array[i].src,
  27.     array[i].dest,
  28.     array[i].type,
  29.     array[i].port,
  30.     array[i].data
  31.     );
  32. printf("%d:%d:%d:%d %s \n");
  33. }
  34. else
  35. {
  36. //if do not meet the condition above writes to correct txt file
  37. n2++;
  38. fprintf(errorFile, "%04d:%04d:%04d:%04d %s \n",
  39.     array[i].src,
  40.     array[i].dest,
  41.     array[i].type,
  42.     array[i].port,
  43.     array[i].data
  44.     );
  45. printf("%d:%d:%d:%d %s \n");
  46. }
  47.     }
  48. fclose(errorFile); //close error output file once done
  49. fclose(outFile); //close correct output file once done
  50. return 0;
  51. }
  52.  
Dec 9 '15 #1
1 1449
weaknessforcats
9,208 Expert Mod 8TB
Have you stepped through this with the debugger?

You need to be sure the array is correct. There's a strlen in there and that means a \0 must end the array and not [i].

Personally, I would write a small driver with a hard-coded array I know is accurate and then step through this logic.
Dec 9 '15 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: J. Muenchbourg | last post by:
I'm getting an Exception occured error on line 4 (For i =1...) <% Function ProperCase(strIn) strOut = "" boolUp = True For i = 1 To Len(strIn) c = Mid(strIn, i, 1) if c = " " or c = "'" or c...
0
by: J. Muenchbourg | last post by:
I'm getting an "exception occured" error pointing to this line : <%=Replace(Replace(rs1("racelength"),"D","")," ","") %> ..when all the other records (84 that i'm displaying) have the same...
1
by: riz | last post by:
We get the following error message. "a floating point exception occured in the user process. current transaction is cancelled". this message comes when trying to excute a stored procedure. This...
0
by: lee | last post by:
I have a TCP/IP client and server I have written in c# using sockets and asynchronous methods. I am having a problem with the server if a client is closed without explicitly disconnecting from the...
1
by: Jay Pondy | last post by:
I have an ASP.Net 2.0 page that inherits from a class that contains a Page_Error handler. In the Page_Error handler I use Server.GetLastError to determine what caused the error. Normally this...
4
by: leelaprasad.gorrepati | last post by:
We had written an application in which we create worker thread. So the main thread will create the worker thread. After some time the child thread(Worker thread) will call pthread_exit(). This...
1
by: platso | last post by:
We had written an application in which we create worker thread. So the main thread will create the worker thread. After some time the child thread(Worker thread) will call pthread_exit()....
1
by: Warren Tang | last post by:
Hi I keeps getting this error periodically. Does anyone know how to find the cause? Or are there some general steps that I can go? Regards Warren
3
by: dylan | last post by:
How to correct the error when odbc Exception was unhandled? Private Function search(ByVal username As String) As Boolean ' Try Dim Sql As String Sql = "Select * from...
4
by: fastestindian | last post by:
Hi, I m getting "Exception occured while reading from the cells." while uploading from a machine. But this issue does not occur from different machine. Please help me, why this is occurring and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
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...
0
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...
0
Oralloy
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,...
0
jinu1996
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.