Like Tree1Likes
  • 1 Post By ZuK

Please help me fix my problem related to c++ code

This is a discussion on Please help me fix my problem related to c++ code within the C++ Programming forums, part of the General Programming Boards category; Code: // WKB.cpp : Defines the entry point for the console application. //the Unit of length is nm, and energy ...

  1. #1
    Registered User
    Join Date
    May 2012
    Posts
    8

    Question Please help me fix my problem related to c++ code

    Code:
    // WKB.cpp : Defines the entry point for the console application.
    
    //the Unit of length is nm, and energy unit is eV, the rest physical quantities are charaterized by I.U.
    
    
    #include<iostream>
    #include <math.h>
    #include <stdio.h>
    #include <stdlib.h>
    using namespace std;
    int main(void)
    {
        
        //define the constant
        double q,pi,vf,h,Ef,V0,Ks,a,Q,v0,omega,lamda,alpha;    
        q=1.6E-19;      //electron charge
        pi=3.141592653;
        vf=1E15;         //fermi velocity for dirac electron in the unit of nm/s
        h=6.63E-34/2/pi/1.6E-19;//reduced plank constant in the unit of eV.s
        Ef=0.082825;         //fermi energy level in the unit of eV
        V0=4.66;        //the work function of graphene sheet is 4.66eV
        v0=0.2;          // the potential barrier height in the unit of eV
        omega=5E13;      // Osscilation frequency of potential
        Ks=2;           //the dimensionlees dielectric constant is 2.3 for graphene sheet
         a=100;          //barrier width in the unit of nm
        lamda=50;       //fermi wavelength in the unit of nm
        alpha=2;            //the effective fine structure constant of graphene
        Q=(Ks-1)/(Ks+1)/4*alpha*h*vf/q*10;    //the constant of the image potential in unit of eV.nm       
            
        //define the variable
        double phi; //phi is the incident angle
        double F;    //F is the applied electric field   
        double U;    //U is the true potential profile
        double x1,x2,x;        //the critical boundray value
        double dx;
        double determine;
        double ky,k11,k01,k02,k12,phi1,phi0,ts0,tsn,Tn,T1,sn;         
        //intialize the parameter
        Tn=U=0;    
        x1=x2=x=0;
        F=0.1/1.602E-19; //in the unit of eV/nm
        errno_t err;
        FILE(*fp);
        err=fopen_s(&fp,"liang 1.txt","w");
        if(err==NULL){
            printf("cannot opent the file \n");
            return 1;
        }
    
    
        for(phi=0;phi<=pi/2;phi=phi+0.005)
                                   {             
                                      ky=(2*pi*sin(phi))/lamda;
                                      k11=sqrt(((Ef+h*omega)*(Ef+h*omega))/(h*h*vf*vf)-ky*ky);
                                      k12=sqrt(((Ef-v0+h*omega)*(Ef-v0+h*omega))/(h*h*vf*vf)-ky*ky);
                                      k01=sqrt((Ef*Ef)/(h*h*vf*vf)-ky*ky);
                                      k02=sqrt(((Ef-v0)*(Ef-v0))/(h*h*vf*vf)-ky*ky);
                                      phi1=atan(ky/k11);
                                      phi0=atan(ky/k01);
                                      ts0=(cos(phi0)*cos(phi0))/(1-cos(k02*a)*cos(k02*a)*sin(phi0)*sin(phi0));
                                      tsn=(cos(phi1)*cos(phi1))/(1-cos(k02*a)*cos(k02*a)*sin(phi1)*sin(phi1));
                        
                                     //calculate the critical boundary value in A    
                                     x1=(V0-v0-Ef*sin(phi))-sqrt((v0-V0+Ef*sin(phi))*(v0-V0+Ef*sin(phi))-4*F*Q)/2/F;
                                     x2=(V0-v0-Ef*sin(phi))+sqrt((v0-V0+Ef*sin(phi))*(v0-V0+Ef*sin(phi))-4*F*Q)/2/F;                        
                                     //printf("%lf %lf %lf %lf\n", x1, x2);
         
                                     //calculate the transmission coefficient                            
                                      dx=(x2-x1)/1000;
                                          for(x=x1+dx;x<=x2-dx;x=x+dx)
                                                                    {
                                                                        U=V0-v0-F*x-Q/x;
                                                                        determine=U/h/omega;
                                                                             if(determine<1)
                                                                                          {                          
                                                                                 T1=ts0*tsn*((2*_j1(U/h/omega))/_j0(U/h/omega))*((2*_j1(U/h/omega))/_j0(U/h/omega))*
                                                                                     (sin((k12-k02)*a/2)*sin((k12-k02)*a/2))/(cos(phi1)*cos(phi1))*(sin(phi0)*sin(phi1)*cos((k02+k12)*a/2)*cos((k02+k12)*a/2)+
                                                                                     cos((phi0+phi1)/2)*cos((phi0+phi1)/2));
                                                                                 Tn=Tn+T1;
                                                                                         }
                                                                             else
                                                                                {
                                                                               break;
                                                                                }
                         
                                                                    }
                                         sn=Tn;                                
                                        fprintf(fp,"%7.5lf \n",sn);
     
                                      }
           fclose(fp);
        return 0;
    }
    No errors appear in the process of building and compile. But when i run the code on the platform VS2010, no results were obtained. Only some tips are shown at the bottom of section of output:

    'my calculation.exe': Loaded 'C:\Users\liang\Documents\Visual Studio 2010\Projects\my calculation\Debug\my calculation.exe', Symbols loaded.
    'my calculation.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Cannot find or open the PDB file
    'my calculation.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Cannot find or open the PDB file
    'my calculation.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Cannot find or open the PDB file
    'my calculation.exe': Loaded 'C:\Windows\SysWOW64\msvcr100d.dll', Symbols loaded.
    The program '[4812] my calculation.exe: Native' has exited with code 1 (0x1).


    I have tried many times, but always failed. Who could help me solve this problem. Thanks!

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,540
    > 'my calculation.exe': Loaded 'C:\Users\liang\Documents\Visual Studio 2010\Projects\my calculation\Debug\my calculation.exe', Symbols loaded.
    This means you can use the debugger to debug your code.

    > 'my calculation.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Cannot find or open the PDB file
    This means you can't use the debugger to debug ntdll.dll (nor would you really want to).

    Neither of these affect how the program runs, only the scope of what you could debug.

    > The program '[4812] my calculation.exe: Native' has exited with code 1 (0x1).
    How many places in your code do you have "return 1;" ?
    Because that's the route the code took when you ran the code.

    From the look of things, it looks like you failed to open the file.


    > err=fopen_s(&fp,"liang 1.txt","w");
    Put a breakpoint on this line (right-click in the left margin and add a breakpoint).
    Then select "debug program" rather than run.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    ZuK
    ZuK is offline
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    Code:
        err=fopen_s(&fp,"liang 1.txt","w");
        if(err==NULL){
            printf("cannot opent the file \n");
            return 1;
        }
    fopen_s() returns 0 if successful

    should be
    Code:
        if(err != 0 ){
    use standard functions

    Kurt
    iMalc likes this.

  4. #4
    Registered User
    Join Date
    May 2012
    Posts
    8

    reply

    Code:
    :redface:
    Quote Originally Posted by Salem View Post
    > 'my calculation.exe': Loaded 'C:\Users\liang\Documents\Visual Studio 2010\Projects\my calculation\Debug\my calculation.exe', Symbols loaded. This means you can use the debugger to debug your code. > 'my calculation.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Cannot find or open the PDB file This means you can't use the debugger to debug ntdll.dll (nor would you really want to). Neither of these affect how the program runs, only the scope of what you could debug. > The program '[4812] my calculation.exe: Native' has exited with code 1 (0x1). How many places in your code do you have "return 1;" ? Because that's the route the code took when you ran the code. From the look of things, it looks like you failed to open the file. > err=fopen_s(&fp,"liang 1.txt","w"); Put a breakpoint on this line (right-click in the left margin and add a breakpoint). Then select "debug program" rather than run.
    Hey, thanks for your reply. I have done debug, and a lot of errors appeared. As for many errors, i v no idea how to fix them. Error 1 error C2144: syntax error : 'double' should be preceded by ';' c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 14 1 my calculation Error 2 error C2059: syntax error : 'if' c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 45 1 my calculation Error 3 error C2447: '{' : missing function header (old-style formal list?) c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 46 1 my calculation Error 4 error C2059: syntax error : 'for' c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 51 1 my calculation Error 5 error C2143: syntax error : missing ')' before ';' c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 51 1 my calculation Error 6 error C2143: syntax error : missing ';' before '<=' c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 51 1 my calculation Error 7 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 51 1 my calculation Error 8 error C2371: 'phi' : redefinition; different basic types c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 51 1 my calculation Error 9 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 51 1 my calculation Error 10 error C2371: 'phi' : redefinition; different basic types c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 51 1 my calculation Error 11 error C2059: syntax error : ')' c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 51 1 my calculation Warning 12 warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 52 1 my calculation Error 13 error C2143: syntax error : missing ';' before '{' c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 52 1 my calculation Error 14 error C2447: '{' : missing function header (old-style formal list?) c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 52 1 my calculation Error 15 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 91 1 my calculation Error 16 error C2365: 'fclose' : redefinition; previous definition was 'function' c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 91 1 my calculation Error 17 error C2440: 'initializing' : cannot convert from 'FILE *' to 'int' c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 91 1 my calculation Error 18 error C2059: syntax error : 'return' c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 92 1 my calculation Error 19 error C2059: syntax error : '}' c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 93 1 my calculation Error 20 error C2143: syntax error : missing ';' before '}' c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 93 1 my calculation Error 21 error C2059: syntax error : '}' c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 93 1 my calculation 22 IntelliSense: expected a declaration c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 45 2 my calculation 23 IntelliSense: expected a declaration c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 46 6 my calculation 24 IntelliSense: expected a declaration c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 51 2 my calculation 25 IntelliSense: expected a declaration c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 74 65 my calculation 26 IntelliSense: this declaration has no storage class or type specifier c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 88 34 my calculation 27 IntelliSense: expected a ')' c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 88 44 my calculation 28 IntelliSense: expected a declaration c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 90 32 my calculation 29 IntelliSense: expected a declaration c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 92 2 my calculation 30 IntelliSense: expected a declaration c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 93 1 my calculation

  5. #5
    Registered User
    Join Date
    May 2012
    Posts
    8

    Post reply to Kurt

    Hey Kurt, thanks for your reply. I tried, but some others errors still appear. Please see the following reply i made to salem. I guess the problem originates from the header file, but i have included the necessary header file into my code. I really dont know what happens?

  6. #6
    ZuK
    ZuK is offline
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    Post the updated code. I have no idea what happened.
    Kurt

  7. #7
    Registered User
    Join Date
    May 2012
    Posts
    8
    Code:
    Quote Originally Posted by ZuK View Post
    Post the updated code. I have no idea what happened. Kurt
    The update code is :#include<iostream>#include <math.h> #include <stdio.h> #include <stdlib.h> using namespace std; int main(void) //define the constant //double q,pi,vf,h,Ef,V0,Ks,a,Q,v0,omega,lamda,alpha; double q=1.6E-19; //electron charge double pi=3.141592653; double vf=1E15; //fermi velocity for dirac electron in the unit of nm/s double h=6.63E-34/2/pi/1.6E-19;//reduced plank constant in the unit of eV.s double Ef=0.082825; //fermi energy level in the unit of eV double V0=4.66; //the work function of graphene sheet is 4.66eV double v0=0.2; // the potential barrier height in the unit of eV double omega=5E13; // Osscilation frequency of potential double Ks=2.; //the dimensionlees dielectric constant is 2.3 for graphene sheet double a=100.; //barrier width in the unit of nm double lamda=50.; //fermi wavelength in the unit of nm double alpha=2.; //the effective fine structure constant of graphene double Q=(Ks-1)/(Ks+1)/4*alpha*h*vf/q*10; //the constant of the image potential in unit of eV.nm //define the variable double phi; //phi is the incident angle //double F; //F is the applied electric field //double U; //U is the true potential profile //double x1,x2,x; //the critical boundray value double dx; double determine; double ky,k11,k01,k02,k12,phi1,phi0,ts0,tsn,T1,sn; //intialize the parameter double Tn=0.; double U=0; double x1=0.; double x2=0; double x=0; double F=0.1/1.602E-19; //in the unit of eV/nm FILE(*fp); errno_t err=fopen_s(&fp,"liang 1.txt","w"); if(err!=0); { printf("cannot opent the file \n"); return 1; } for(phi=0;phi<=pi/2;phi=phi+0.005) { ky=(2*pi*sin(phi))/lamda; k11=sqrt(((Ef+h*omega)*(Ef+h*omega))/(h*h*vf*vf)-ky*ky); k12=sqrt(((Ef-v0+h*omega)*(Ef-v0+h*omega))/(h*h*vf*vf)-ky*ky); k01=sqrt((Ef*Ef)/(h*h*vf*vf)-ky*ky); k02=sqrt(((Ef-v0)*(Ef-v0))/(h*h*vf*vf)-ky*ky); phi1=atan(ky/k11); phi0=atan(ky/k01); ts0=(cos(phi0)*cos(phi0))/(1-cos(k02*a)*cos(k02*a)*sin(phi0)*sin(phi0)); tsn=(cos(phi1)*cos(phi1))/(1-cos(k02*a)*cos(k02*a)*sin(phi1)*sin(phi1)); //calculate the critical boundary value in A x1=(V0-v0-Ef*sin(phi))-sqrt((v0-V0+Ef*sin(phi))*(v0-V0+Ef*sin(phi))-4*F*Q)/2/F; x2=(V0-v0-Ef*sin(phi))+sqrt((v0-V0+Ef*sin(phi))*(v0-V0+Ef*sin(phi))-4*F*Q)/2/F; //printf("%lf %lf %lf %lf\n", x1, x2); //calculate the transmission coefficient dx=(x2-x1)/1000; for(x=x1+dx;x<=x2-dx;x=x+dx) { U=V0-v0-F*x-Q/x; determine=U/h/omega; if(determine<1) { T1=ts0*tsn*((2*_j1(U/h/omega))/_j0(U/h/omega))*((2*_j1(U/h/omega))/_j0(U/h/omega))* (sin((k12-k02)*a/2)*sin((k12-k02)*a/2))/(cos(phi1)*cos(phi1))*(sin(phi0)*sin(phi1)*cos((k02+k12)*a/2)*cos((k02+k12)*a/2)+ cos((phi0+phi1)/2)*cos((phi0+phi1)/2)); Tn=Tn+T1; } else { break; } } sn=Tn; fprintf(fp,"%7.5lf \n",sn); } fclose(fp); return 0; } And the errors shown in the following: Error 1 error C2144: syntax error : 'double' should be preceded by ';' c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 14 1 my calculation Error 2 error C2059: syntax error : 'if' c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 45 1 my calculation Error 3 error C2447: '{' : missing function header (old-style formal list?) c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 46 1 my calculation Error 4 error C2059: syntax error : 'for' c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 51 1 my calculation Error 5 error C2143: syntax error : missing ')' before ';' c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 51 1 my calculation Error 6 error C2143: syntax error : missing ';' before '<=' c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 51 1 my calculation Error 7 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 51 1 my calculation Error 8 error C2371: 'phi' : redefinition; different basic types c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 51 1 my calculation Error 9 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 51 1 my calculation Error 10 error C2371: 'phi' : redefinition; different basic types c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 51 1 my calculation Error 11 error C2059: syntax error : ')' c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 51 1 my calculation Warning 12 warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 52 1 my calculation Error 13 error C2143: syntax error : missing ';' before '{' c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 52 1 my calculation Error 14 error C2447: '{' : missing function header (old-style formal list?) c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 52 1 my calculation Error 15 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 91 1 my calculation Error 16 error C2365: 'fclose' : redefinition; previous definition was 'function' c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 91 1 my calculation Error 17 error C2440: 'initializing' : cannot convert from 'FILE *' to 'int' c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 91 1 my calculation Error 18 error C2059: syntax error : 'return' c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 92 1 my calculation Error 19 error C2059: syntax error : '}' c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 93 1 my calculation Error 20 error C2143: syntax error : missing ';' before '}' c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 93 1 my calculation Error 21 error C2059: syntax error : '}' c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 93 1 my calculation 22 IntelliSense: expected a declaration c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 45 2 my calculation 23 IntelliSense: expected a declaration c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 46 6 my calculation 24 IntelliSense: expected a declaration c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 51 2 my calculation 25 IntelliSense: this declaration has no storage class or type specifier c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 69 29 my calculation 26 IntelliSense: expected a declaration c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 70 36 my calculation 27 IntelliSense: this declaration has no storage class or type specifier c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 88 34 my calculation 28 IntelliSense: expected a ')' c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 88 44 my calculation 29 IntelliSense: expected a declaration c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 90 32 my calculation 30 IntelliSense: expected a declaration c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 92 2 my calculation 31 IntelliSense: expected a declaration c:\users\liang\documents\visual studio 2010\projects\my calculation\my calculation\tunneling transmission.cpp 93 1 my calculation

  8. #8
    ZuK
    ZuK is offline
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    Code:
    int main(void) {  // <- missing brace

  9. #9
    Registered User
    Join Date
    May 2012
    Posts
    8
    Quote Originally Posted by ZuK View Post
    Code:
    int main(void) {  // <- missing brace
    Yes, i added the brace, and run the code again, and the tips shown at the section of output become the following:
    'my calculation.exe': Loaded 'C:\Users\liang\Documents\Visual Studio 2010\Projects\my calculation\Debug\my calculation.exe', Symbols loaded.
    'my calculation.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Cannot find or open the PDB file
    'my calculation.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Cannot find or open the PDB file
    'my calculation.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Cannot find or open the PDB file
    'my calculation.exe': Loaded 'C:\Windows\SysWOW64\msvcr100d.dll', Symbols loaded.

    Compared with the original code, only a tip"he program '[4812] my calculation.exe: Native' has exited with code 1 (0x1)." is eliminated. But how to caused the other tips?
    "

  10. #10
    ZuK
    ZuK is offline
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    see post #2
    Kurt

  11. #11
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,701
    Salem's initial post tells you what you need to know about those lines of output.

    So does your program produce an output file yet?

    Can you explain the steps you took to get that output? If you explain that in some detail maybe we can tell you what to do so you don't get that output about PDB files. Since it's a bunch of dlls you might be trying to debug the wrong type of build.

  12. #12
    Registered User
    Join Date
    May 2012
    Posts
    8
    Quote Originally Posted by zuk View Post
    see post #2
    kurt
    i have revised this mistake in the last poster according to post#2, and indeed the file can not be opened. How to make correction to the following code to open the file?
    Code:
    file(*fp);
    	errno_t err=fopen_s(&fp,"liang 1.txt","w");
    	if(err!=0);
         {
      printf("cannot opent the file \n");
      return 1;
         }



  13. #13
    Registered User
    Join Date
    May 2012
    Posts
    8
    Quote Originally Posted by whiteflags View Post
    Salem's initial post tells you what you need to know about those lines of output.

    So does your program produce an output file yet?

    Can you explain the steps you took to get that output? If you explain that in some detail maybe we can tell you what to do so you don't get that output about PDB files. Since it's a bunch of dlls you might be trying to debug the wrong type of build.
    Thanks for your reply.Now i followed Kurt's opinions, all of errors have been eliminated except that the file can not be opened. So i don't know where is wrong about the code of opening the file. Could you help me check the code?

    Code:
    FILE(*fp);
    	errno_t err=fopen_s(&fp,"liang 1.txt","w");
    	if(err!=0);
         {
      printf("cannot opent the file \n");
      return 1;
         }

  14. #14
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,701
    Code:
    file(*fp);
        errno_t err=fopen_s(&fp,"liang 1.txt","w");
        if(err!=0);
         {
      printf("cannot opent the file \n");
      return 1;
         }
    Is that really what's there? I mean you said that the program doesn't exit with 1 anymore so that seems contradictory.
    1. don't put semi-colons after if statements because that is a no-op, and in turn, causes the block to be executed underneath at all times.
    2. file(*fp); is a very awkward way to spell FILE *fp;
    3. It's annoying how your braces are vertically spaced so much yet all your code is so crammed together.

    Compared with the original code, only a tip"he program '[4812] my calculation.exe: Native' has exited with code 1 (0x1)." is eliminated.
    Per 1, it would be there still if the right code path was taken.

    Also it would be really good if you stopped quoting your entire post.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A problem related to array
    By rgqwlooo in forum C Programming
    Replies: 3
    Last Post: 01-15-2012, 04:36 PM
  2. Replies: 3
    Last Post: 07-23-2011, 02:24 AM
  3. Pointer related problem
    By shashinitjsr in forum C Programming
    Replies: 2
    Last Post: 06-25-2011, 02:37 AM
  4. Question related to returning to earlier parts of the code.
    By Cgrasshopper in forum C Programming
    Replies: 2
    Last Post: 03-13-2010, 10:00 PM
  5. Understang this malloc() related code
    By lambs4 in forum C Programming
    Replies: 6
    Last Post: 11-30-2001, 04:13 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21