Click here to Skip to main content
15,887,845 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Knowing when no data is @ Serial Port Pin
Mircea Puiu24-Mar-05 5:15
Mircea Puiu24-Mar-05 5:15 
GeneralMFC Chart Pin
Coremn23-Mar-05 13:19
Coremn23-Mar-05 13:19 
GeneralRe: MFC Chart Pin
David Crow23-Mar-05 16:48
David Crow23-Mar-05 16:48 
GeneralRe: MFC Chart Pin
Coremn23-Mar-05 16:53
Coremn23-Mar-05 16:53 
GeneralOpenGL and CView problem Pin
FayezElFar23-Mar-05 11:50
FayezElFar23-Mar-05 11:50 
GeneralRe: OpenGL and CView problem Pin
Alexander M.,23-Mar-05 12:19
Alexander M.,23-Mar-05 12:19 
GeneralRe: OpenGL and CView problem Pin
FayezElFar24-Mar-05 4:25
FayezElFar24-Mar-05 4:25 
GeneralSimple error, but how to solve?:( Pin
sacoskun23-Mar-05 10:01
sacoskun23-Mar-05 10:01 
Hi, I have a simple code but I couldn't make it run...

#include "stdafx.h"<br />
<br />
typedef int DataType;<br />
<br />
const int MAX_SIZE = 50;<br />
<br />
void merge(DataType theArray[], int first, int mid, int last);<br />
void mergesort(DataType theArray[], int first, int last)<br />
<br />
int _tmain(int argc, _TCHAR* argv[])<br />
{<br />
	int arrayToSend[4] = { 1, 2, 4, 3 };<br />
	mergesort( arrayToSend, 0, 3 );<br />
	return 0;<br />
}<br />
<br />
void merge(DataType theArray[], int first, int mid, int last)<br />
{<br />
   DataType tempArray[MAX_SIZE];    // temporary array<br />
<br />
   // initialize the local indexes to indicate the subarrays<br />
   int first1 = first;       // beginning of first subarray<br />
   int last1  = mid;         // end of first subarray<br />
   int first2 = mid + 1;     // beginning of second subarray<br />
   int last2  = last;        // end of second subarray<br />
<br />
   // while both subarrays are not empty, copy the<br />
   // smaller item into the temporary array<br />
   int index = first1;    // next available location in <br />
                          // tempArray<br />
   for (; (first1 <= last1) && (first2 <= last2); ++index)<br />
   {  // Invariant: tempArray[first1..index-1] is in order<br />
      if (theArray[first1] < theArray[first2])<br />
      {  tempArray[index] = theArray[first1];<br />
         ++first1;<br />
      }<br />
      else<br />
      {  tempArray[index] = theArray[first2];<br />
         ++first2;<br />
      }  // end if<br />
   }  // end for<br />
<br />
   // finish off the nonempty subarray<br />
<br />
   // finish off the first subarray, if necessary<br />
   for (; first1 <= last1; ++first1, ++index)<br />
      // Invariant: tempArray[first1..index-1] is in order<br />
      tempArray[index] = theArray[first1];<br />
<br />
   // finish off the second subarray, if necessary<br />
   for (; first2 <= last2; ++first2, ++index)<br />
      // Invariant: tempArray[first1..index-1] is in order<br />
      tempArray[index] = theArray[first2];<br />
<br />
   // copy the result back into the original array<br />
   for (index = first; index <= last; ++index)<br />
      theArray[index] = tempArray[index];<br />
}  // end merge<br />
<br />
void mergesort(DataType theArray[], int first, int last)<br />
{<br />
   if (first < last)<br />
   {  // sort each half<br />
      int mid = (first + last)/2;    // index of midpoint<br />
      // sort left half theArray[first..mid]<br />
      mergesort(theArray, first, mid);<br />
      // sort right half theArray[mid+1..last]<br />
      mergesort(theArray, mid+1, last);<br />
<br />
      // merge the two halves<br />
      merge(theArray, first, mid, last);<br />
   }  // end if<br />
}  // end mergesort


I get errors like

d:\CD\myProjects\Homeworks\hw2Q4\hw2Q4.cpp(5): warning C4518: 'int ' : storage-class or type specifier(s) unexpected here; ignored

d:\CD\myProjects\Homeworks\hw2Q4\hw2Q4.cpp(5): error C2146: syntax error : missing ';' before identifier 'main'

d:\CD\myProjects\Homeworks\hw2Q4\hw2Q4.cpp(13): fatal error C1075: end of file found before the left brace '{' at 'd:\CD\myProjects\Homeworks\hw2Q4\hw2Q4.cpp(11)' was matched


Any help would be appriciated.
GeneralRe: Simple error, but how to solve?:( Pin
PJ Arends23-Mar-05 10:09
professionalPJ Arends23-Mar-05 10:09 
GeneralRe: Simple error, but how to solve?:( Pin
sacoskun23-Mar-05 10:21
sacoskun23-Mar-05 10:21 
GeneralRe: Simple error, but how to solve?:( Pin
Barry Etter23-Mar-05 10:39
Barry Etter23-Mar-05 10:39 
GeneralRe: Simple error, but how to solve?:( Pin
sacoskun23-Mar-05 10:43
sacoskun23-Mar-05 10:43 
GeneralRe: Simple error, but how to solve?:( Pin
Barry Etter23-Mar-05 10:53
Barry Etter23-Mar-05 10:53 
GeneralRe: Simple error, but how to solve?:( Pin
PJ Arends23-Mar-05 10:55
professionalPJ Arends23-Mar-05 10:55 
GeneralRe: Simple error, but how to solve?:( Pin
sacoskun23-Mar-05 11:15
sacoskun23-Mar-05 11:15 
GeneralRe: Simple error, but how to solve?:( Pin
Serge Krynine23-Mar-05 11:54
Serge Krynine23-Mar-05 11:54 
GeneralRe: Simple error, but how to solve?:( Pin
sacoskun23-Mar-05 18:13
sacoskun23-Mar-05 18:13 
GeneralNeed some direction Pin
Tom Wright23-Mar-05 9:55
Tom Wright23-Mar-05 9:55 
GeneralRe: Need some direction Pin
PJ Arends23-Mar-05 10:59
professionalPJ Arends23-Mar-05 10:59 
GeneralRe: Need some direction Pin
Tom Wright23-Mar-05 11:21
Tom Wright23-Mar-05 11:21 
Questionneed a tool (or api) that creates login attempts to an active directory domain?? Pin
vista2723-Mar-05 9:25
vista2723-Mar-05 9:25 
AnswerRe: need a tool (or api) that creates login attempts to an active directory domain?? Pin
Blake Miller23-Mar-05 11:43
Blake Miller23-Mar-05 11:43 
QuestionHow to detect Network Cable Unplug Events Pin
Paolo Ponzano23-Mar-05 8:36
Paolo Ponzano23-Mar-05 8:36 
AnswerRe: How to detect Network Cable Unplug Events Pin
David Crow23-Mar-05 9:45
David Crow23-Mar-05 9:45 
GeneralHardware list error Pin
brilliant10123-Mar-05 8:10
brilliant10123-Mar-05 8:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.