473,387 Members | 1,650 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.

Segmentation Fault - No Idea Why Tried the Little I know

I am new to C programming and am still at an early level in java and C#. I am posting regarding a segmentation fault error code I get when I try to run a program that I am developing. I am coding on an Ubuntu Linux computer and am compiling using gcc. Basically what the program is supposed to do is first using "scanf()" it will read in two values from the user into variables, and those variables will then be passed to a method which will use those variables to issue a "system()" function command which will use the arguments accepted from the user to issue an "mplayer" command to the command line. I have tried all that I know to fix the problem (which is basically substituting "%c" for "%s") but to be honest I really have absolutely no idea why I am getting a Segmentation Fault when I run this program(the error occurs after I have read in both values from the user, so I guess I could be passing to the method incorrectly, but really I just don't know). Below is the code for the program I have been talking about, if you can spot what is causing the segmentation fault and explain it to me and if possible how I can correct it I would really appreciate it, I look forward to participating in this forum.
Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <syscall.h>
  4. #include <unistd.h>
  5. #include <stdio.h>
  6. #include <sys/types.h>
  7. int main()
  8. {
  9.         char *source;
  10.         char *param;
  11.         printf("Please Enter a Source URL to be recorded\n");
  12.         sscanf("%s",&source);
  13.         printf("\nPlease Enter a file to hold the datastream from the URL\n");
  14.         sscanf("%s",&param);
  15.         getparameters(source, param);
  16.         return 0;
  17. }
  18. int getparameters(char *url, char *outfile)
  19. {
  20.         char *tempurl = url;
  21.         char *tempoutfile = outfile;
  22.         char *mplayer1 = "mplayer -dumpstream ";
  23.         char *mplayer2 = " -dumpfile ";
  24.         char *mplayexec;
  25.         sprintf(mplayexec,"%c%c%c%c",mplayer1,tempurl,mplayer2,tempoutfile);
  26.         printf("\n");
  27.         system(mplayerexec);
  28.         return 0;
  29. }
  30.  
Dec 29 '06 #1
14 1937
macklin01
145 100+
I am new to C programming and am still at an early level in java and C#. I am posting regarding a segmentation fault error code I get when I try to run a program that I am developing. I am coding on an Ubuntu Linux computer and am compiling using gcc. Basically what the program is supposed to do is first using "scanf()" it will read in two values from the user into variables, and those variables will then be passed to a method which will use those variables to issue a "system()" function command which will use the arguments accepted from the user to issue an "mplayer" command to the command line. I have tried all that I know to fix the problem (which is basically substituting "%c" for "%s") but to be honest I really have absolutely no idea why I am getting a Segmentation Fault when I run this program(the error occurs after I have read in both values from the user, so I guess I could be passing to the method incorrectly, but really I just don't know). Below is the code for the program I have been talking about, if you can spot what is causing the segmentation fault and explain it to me and if possible how I can correct it I would really appreciate it, I look forward to participating in this forum.
Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <syscall.h>
  4. #include <unistd.h>
  5. #include <stdio.h>
  6. #include <sys/types.h>
  7. int main()
  8. {
  9.         char *source;
  10.         char *param;
  11.         printf("Please Enter a Source URL to be recorded\n");
  12.         sscanf("%s",&source);
  13.         printf("\nPlease Enter a file to hold the datastream from the URL\n");
  14.         sscanf("%s",&param);
  15.         getparameters(source, param);
  16.         return 0;
  17. }
  18. int getparameters(char *url, char *outfile)
  19. {
  20.         char *tempurl = url;
  21.         char *tempoutfile = outfile;
  22.         char *mplayer1 = "mplayer -dumpstream ";
  23.         char *mplayer2 = " -dumpfile ";
  24.         char *mplayexec;
  25.         sprintf(mplayexec,"%c%c%c%c",mplayer1,tempurl,mplayer2,tempoutfile);
  26.         printf("\n");
  27.         system(mplayerexec);
  28.         return 0;
  29. }
  30.  
You need to allocate memory for the following: source, param, mplayexec. e.g.,

Expand|Select|Wrap|Line Numbers
  1. char* source;
  2. source = new char [1024];
  3.  
That should probably do it. -- Paul
Dec 29 '06 #2
Well, I tried allocating memory for each of the variables as Paul suggested, but now I get the following compiler errors:

Expand|Select|Wrap|Line Numbers
  1. mplayerschedule.c: In function ‘getparameters’:
  2. mplayerschedule.c:25: error: incompatible types in assignment
  3. mplayerschedule.c:32: error: incompatible types in assignment
  4. mplayerschedule.c:36: error: incompatible types in assignment
  5. mplayerschedule.c:39: warning: passing argument 1 of ‘sprintf’ from incompatible pointer type
I again, have no idea why these error codes are being generated, as I do not see what is wrong with any of the declarations I have made (even at the specified lines) or how I am passing incompatible data to sprintf, could someone please review my revised code and see where I went wrong? Thanks.

Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <syscall.h>
  4. #include <unistd.h>
  5. #include <stdio.h>
  6. #include <sys/types.h>
  7. int main()
  8. {
  9.     char* source[1024];
  10.     //source = new char* [1024];
  11.     char* param[1024];
  12.     //param = new char* [1024];
  13.     printf("Please Enter a Source URL to be recorded\n");
  14.     scanf("%s",&source);
  15.     printf("\nPlease Enter a file to hold the datastream from the URL\n");
  16.     scanf("%s",&param);
  17.     getparameters(source, param);
  18.     return 0;
  19. }
  20. int getparameters(char* url[1024], char* outfile[1024])
  21. {
  22.     //char *tempurl = url;
  23.     char* tempurl[1024];
  24.     //tempurl = new char* [1024];
  25.     tempurl = url;
  26.     //char *tempoutfile = outfile;
  27.     char* tempoutfile[1024];
  28.     //tempoutfile = new char* [1024];
  29.     //char *mplayer1 = "mplayer -dumpstream ";
  30.     char* mplayer1[1024];
  31.     //mplayer1 = new char* [1024];
  32.     mplayer1 = "mplayer -dumpstream ";
  33.     //char *mplayer2 = " -dumpfile ";
  34.     char* mplayer2[1024];
  35.     //mplayer2 = new char* [1024];
  36.     mplayer2 = " -dumpfile ";
  37.     char* mplayexec[1024];
  38.     //mplayerexec = new char* [1024];
  39.     sprintf(mplayexec,"%s%s%s%s",mplayer1,tempurl,mplayer2,tempoutfile);
  40.     printf("\n");
  41.     system(mplayexec);
  42.     return 0;
  43. }
  44.  
  45.  
Dec 29 '06 #3
macklin01
145 100+
Well, I tried allocating memory for each of the variables as Paul suggested, but now I get the following compiler errors *snip*
Expand|Select|Wrap|Line Numbers
  1.     char* source[1024];
  2.     //source = new char* [1024];
  3.  
What you've done here is allocate 1024 memory addresses of characters. What you really want is 1024 characters. You need to do it like this (in two steps):

Expand|Select|Wrap|Line Numbers
  1. char* source;
  2. source = new char [1024];
  3. char* param;
  4. param =new char [1024];
  5.  
and so forth.

Also, this is perfectly fine:
Expand|Select|Wrap|Line Numbers
  1. char* blah = "blah blah blah blah";
  2.  
That's why I only flagged certain char* parts for needing allocation. (Although I may have missed some.)

Lastly, nice work on switching from %c to %s in your sprintf line toward the end. Keep at it; you're almost there! :) -- Paul
Dec 29 '06 #4
Forgive me if I am wrong, but isn't this object oriented C++ syntax? I am using C only.
Expand|Select|Wrap|Line Numbers
  1. char* tempoutfile;
  2.     tempoutfile = new char [1024];
When I do as you suggest I get the following compiler errors:
Expand|Select|Wrap|Line Numbers
  1. mplayerschedule.c: In function ‘main’:
  2. mplayerschedule.c:10: error: ‘new’ undeclared (first use in this function)
  3. mplayerschedule.c:10: error: (Each undeclared identifier is reported only once
  4. mplayerschedule.c:10: error: for each function it appears in.)
  5. mplayerschedule.c:10: error: syntax error before ‘char’
  6. mplayerschedule.c:12: error: syntax error before ‘char’
  7. mplayerschedule.c: In function ‘getparameters’:
  8. mplayerschedule.c:24: error: ‘new’ undeclared (first use in this function)
  9. mplayerschedule.c:24: error: syntax error before ‘char’
  10. mplayerschedule.c:28: error: syntax error before ‘char’
  11. mplayerschedule.c:31: error: syntax error before ‘char’
  12. mplayerschedule.c:35: error: syntax error before ‘char’
  13. mplayerschedule.c:38: error: ‘mplayerexec’ undeclared (first use in this function)
  14. mplayerschedule.c:38: error: syntax error before ‘char’
does "‘new’ undeclared " mean that the compiler is not recognizing "new" as a keyword? Here is my latest revised code, thanks more help you can offer on this, hopefully I'll get it next time :)

Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <syscall.h>
  4. #include <unistd.h>
  5. #include <stdio.h>
  6. #include <sys/types.h>
  7. int main()
  8. {
  9.     char* source;
  10.     source = new char [1024];
  11.     char* param;
  12.     param = new char [1024];
  13.     printf("Please Enter a Source URL to be recorded\n");
  14.     scanf("%s",&source);
  15.     printf("\nPlease Enter a file to hold the datastream from the URL\n");
  16.     scanf("%s",&param);
  17.     getparameters(source, param);
  18.     return 0;
  19. }
  20. int getparameters(char* url, char* outfile)
  21. {
  22.     //char *tempurl = url;
  23.     char* tempurl;
  24.     tempurl = new char [1024];
  25.     tempurl = url;
  26.     //char *tempoutfile = outfile;
  27.     char* tempoutfile;
  28.     tempoutfile = new char [1024];
  29.     //char *mplayer1 = "mplayer -dumpstream ";
  30.     char* mplayer1;
  31.     mplayer1 = new char [1024];
  32.     mplayer1 = "mplayer -dumpstream ";
  33.     //char *mplayer2 = " -dumpfile ";
  34.     char* mplayer2;
  35.     mplayer2 = new char [1024];
  36.     mplayer2 = " -dumpfile ";
  37.     char* mplayexec;
  38.     mplayerexec = new char [1024];
  39.     sprintf(mplayexec,"%s%s%s%s",mplayer1,tempurl,mplayer2,tempoutfile);
  40.     printf("\n");
  41.     system(mplayexec);
  42.     return 0;
  43. }
  44.  
Dec 29 '06 #5
macklin01
145 100+
Forgive me if I am wrong, but isn't this object oriented C++ syntax? I am using C only.
Do'h! I'm so sorry--you're completely right. I hadn't noticed that you were using C rather than C++. (A rather poor assumption on my part.)

You'll need to use malloc instead. I'll post again soon with some corrections. (I need to finish proofreading a paper before I meet with my advisor tomorrow.) Thanks, and once again, good point. -- Paul

PS: Is there a particular reason to use C instead of C++ for this project, as it appears to be a launcher for mplayer. I'm just curious. Thanks -- Paul
Dec 29 '06 #6
Well, I really do appreciate the help you have given me thus far. I am using C for this project because I don't need to deal with too much complexity for this program and I feel that using OOP would be a little over kill. Eventually I'm planning to use it to read a text file that I have thrown links into for stream recording, but I wanted to get the most basic part of my idea up and running first, that being launching mplayer and recording a stream entered in by the user. Well, I thank you for any further help that you can provide, thank you for taking the time to help me this far.
Dec 29 '06 #7
Hello,
As mentioned in previous post, you need to allocate memory for the strings source,param,etc. using malloc as follows:

Expand|Select|Wrap|Line Numbers
  1.  
  2. char *source;
  3.  
  4. source = (char *) malloc(1024);
  5.  
  6.  
The prototype for malloc() is void* malloc(size_t); So the casting is required.

Regards,
Dec 29 '06 #8
Thanks for the reply vpawizard. I tried using the "malloc()" function in the way you suggested, but I am still getting a segmentation fault error when I run the application. Should I be setting up the parameter differently here:
Expand|Select|Wrap|Line Numbers
  1. int getparameters(char *url, char *outfile)
and if I should change the parameter layout, how do I do it?

Here is the code for the entire program with my attempt at the changes you suggest. Thanks again for any help with this you can provide, hopefully I am getting closer to solution with each attempt :)

Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <malloc.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <syscall.h>
  6. #include <unistd.h>
  7. #include <stdio.h>
  8. #include <sys/types.h>
  9. int main()
  10. {
  11.     char *source;
  12.     source = (char *) malloc(1024);
  13.     char *param;
  14.     param = (char *) malloc(1024);
  15.     printf("Please Enter a Source URL to be recorded\n");
  16.     scanf("%s",&source);
  17.     printf("\nPlease Enter a file to hold the datastream from the URL\n");
  18.     scanf("%s",&param);
  19.     getparameters(source, param);
  20.     return 0;
  21. }
  22. int getparameters(char *url, char *outfile)
  23. {
  24.     //char *tempurl = url;
  25.     char *tempurl;
  26.     tempurl = (char *) malloc(1024);
  27.     tempurl = url;
  28.     //char *tempoutfile = outfile;
  29.     char *tempoutfile;
  30.     tempoutfile = (char *) malloc(1024);
  31.     //char *mplayer1 = "mplayer -dumpstream ";
  32.     char *mplayer1;
  33.     mplayer1 = (char *) malloc(1024);
  34.     mplayer1 = "mplayer -dumpstream ";
  35.     //char *mplayer2 = " -dumpfile ";
  36.     char *mplayer2;
  37.     mplayer2 = (char *) malloc(1024);
  38.     mplayer2 = " -dumpfile ";
  39.     char *mplayexec;
  40.     mplayexec = (char *) malloc(1024);
  41.     sprintf(mplayexec,"%s%s%s%s",mplayer1,tempurl,mplayer2,tempoutfile);
  42.     printf("\n %s\n",mplayexec);
  43.     printf("\n");
  44.     system(mplayexec);
  45.     return 0;
  46. }
  47.  
Dec 29 '06 #9
I'm still pretty much lost here, if someone has any idea on what I am doing wrong as far as the allocation of memory, or the passing of the argument goes, I'd be very greatful. :)
Dec 31 '06 #10
horace1
1,510 Expert 1GB
for a start the variables source and param are addresses (i.e. char*) so you don't need the & (the addressof operator) in the calls to scanf, e.g. your main() then becomes
Expand|Select|Wrap|Line Numbers
  1. int main()
  2. {
  3.     char *source;
  4.     source = (char *) malloc(1024);
  5.     char *param;
  6.     param = (char *) malloc(1024);
  7.     printf("Please Enter a Source URL to be recorded\n");
  8.     scanf("%s",source);   // ** remove &
  9.     printf("source %s\n", source);
  10.     printf("\nPlease Enter a file to hold the datastream from the URL\n");
  11.     scanf("%s",param);      // ** remove &
  12.     printf("param %s\n", param);
  13.     getparameters(source, param);
  14.     return 0;
  15. }
  16.  
Dec 31 '06 #11
Thank you for your reply Horace1. I have made other changes to the program because I believe that based on the point at run time when I would get a segmentation fault error before and the compiler errors that I am getting now, I believe that I have pegged my problem down as something to do with how I am passing the argument to the getparameters() function and / or how I am declaring the parameters in the getparameters() function. Here is my code as it stands now. I suppose what I reallly need help with now is getting the getparameters() set up to recieve the values correctly. So here is the program as it stands now with the changes I made:

Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <malloc.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <syscall.h>
  6. #include <unistd.h>
  7. #include <stdio.h>
  8. #include <sys/types.h>
  9. void getparameters(char url[127], char outfile[127]);
  10. int main()
  11. {
  12.         char source[127];
  13.         char param[127];
  14.         printf("Please Enter a Source URL to be recorded\n");
  15.         scanf("%s",&source);
  16.         printf("\nPlease Enter a file to hold the datastream from the URL\n");
  17.         scanf("%s",&param);
  18.         getparameters(source, param);
  19.         return 0;
  20. }
  21. void getparameters(char url[127], char outfile[127])
  22. {
  23.         char tempurl[127];
  24.         tempurl = url;
  25.         char tempoutfile[127];
  26.         tempoutfile = outfile;
  27.         char mplayer1[127];
  28.         mplayer1 = "mplayer -dumpstream ";
  29.         char mplayer2[127];
  30.         mplayer2 = " -dumpfile ";
  31.         char mplayexec[127];
  32.         sprintf(mplayexec,"%s%s%s%s",mplayer1,tempurl,mplayer2,tempoutfile);
  33.         printf("\n %s\n",mplayexec);
  34.         printf("\n");
  35.         system(mplayexec);
  36. }
If you spot problems other than the type I think I have, please feel free to explain and / or correct them.

Here are the compiler errors that I now recieve:
Expand|Select|Wrap|Line Numbers
  1. mplayerschedule.c: In function ‘getparameters’:
  2. mplayerschedule.c:24: error: incompatible types in assignment
  3. mplayerschedule.c:26: error: incompatible types in assignment
  4. mplayerschedule.c:28: error: incompatible types in assignment
  5. mplayerschedule.c:30: error: incompatible types in assignment
I get them regardless of whether or not I use scanf() like this:

Expand|Select|Wrap|Line Numbers
  1. scanf("%s",&source);
or like this:

Expand|Select|Wrap|Line Numbers
  1. scanf("%s",source);
so I don't believe I am using scanf() incorrectly. Well sorry about seemingly going about in circles here, hopefully I'm close. Thanks for any help possible.
Jan 1 '07 #12
Horace1, I don't know what was going through my brain in my last post, I guess I woke up some what you posted clicked in my brain. Here is my corrected code that works, thanks for all of the help, but if possible, could you explain in a little bit of detail why my code wasn't working before, I only have a general idea as of now, but thanks again to all who helped me with this problem, this is a great forum! I will probably be back when I expand this into a more practical program...

Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <malloc.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <syscall.h>
  6. #include <unistd.h>
  7. #include <stdio.h>
  8. #include <sys/types.h>
  9. int getparameters(char *url, char *outfile);
  10. int main()
  11. {
  12.     char *source;
  13.     source = (char *) malloc(1024);
  14.     char *param;
  15.     param = (char *) malloc(1024);
  16.     printf("Please Enter a Source URL to be recorded\n");
  17.     scanf("%s",source);   // ** remove &
  18.     printf("source %s\n", source);
  19.     printf("\nPlease Enter a file to hold the datastream from the URL\n");
  20.     scanf("%s",param);      // ** remove &
  21.     printf("param %s\n", param);
  22.     getparameters(source, param);
  23.     return 0;
  24. }
  25. int getparameters(char *url, char *outfile)
  26. {
  27.     //char *tempurl = url;
  28.     char *tempurl;
  29.     tempurl = (char *) malloc(1024);
  30.     tempurl = url;
  31.     //char *tempoutfile = outfile;
  32.     char *tempoutfile;
  33.     tempoutfile = (char *) malloc(1024);
  34.     tempoutfile = outfile;
  35.     //char *mplayer1 = "mplayer -dumpstream ";
  36.     char *mplayer1;
  37.     mplayer1 = (char *) malloc(1024);
  38.     mplayer1 = "mplayer -dumpstream ";
  39.     //char *mplayer2 = " -dumpfile ";
  40.     char *mplayer2;
  41.     mplayer2 = (char *) malloc(1024);
  42.     mplayer2 = " -dumpfile ";
  43.     char *mplayexec;
  44.     mplayexec = (char *) malloc(1024);
  45.     //char *mplayexec2;
  46.     //mplayexec2 = (char *) malloc(1024);
  47.     sprintf(mplayexec,"%s%s%s%s",mplayer1,tempurl,mplayer2,tempoutfile);
  48.     //sprintf(mplayexec,"%s%s",mplayexec2,tempoutfile);
  49.     printf("\n %s\n",mplayexec);
  50.     printf("\n");
  51.     system(mplayexec);
  52.     return 0;
  53. }
Jan 1 '07 #13
horace1
1,510 Expert 1GB

Here are the compiler errors that I now recieve:
Expand|Select|Wrap|Line Numbers
  1. mplayerschedule.c: In function ‘getparameters’:
  2. mplayerschedule.c:24: error: incompatible types in assignment
  3. mplayerschedule.c:26: error: incompatible types in assignment
  4. mplayerschedule.c:28: error: incompatible types in assignment
  5. mplayerschedule.c:30: error: incompatible types in assignment
so I don't believe I am using scanf() incorrectly. Well sorry about seemingly going about in circles here, hopefully I'm close. Thanks for any help possible.
your problem with these statements
Expand|Select|Wrap|Line Numbers
  1.         char tempurl[127];
  2.         tempurl = url;
  3.  
is that you cannot assign the contents of one array (such as url) to another (such as tempurl). With char[] arrays you can use string copy functions
Expand|Select|Wrap|Line Numbers
  1.         strncpy(tempurl, url, 127);  // ** use strncpy
  2.  
Jan 1 '07 #14
horace1
1,510 Expert 1GB
your new program using malloc() is a bit complex - you can use strncpy() in the previous program, e.g.
Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <malloc.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. //#include <syscall.h>
  6. #include <unistd.h>
  7. #include <stdio.h>
  8. #include <sys/types.h>
  9. void getparameters(char url[127], char outfile[127]);
  10. int main()
  11. {
  12.         char source[127];
  13.         char param[127];
  14.         printf("Please Enter a Source URL to be recorded\n");
  15.         scanf("%s", source);  // ** remove &
  16.         printf("\nPlease Enter a file to hold the datastream from the URL\n");
  17.         scanf("%s",param);  // ** remove &
  18.         getparameters(source, param);
  19.         system("pause");
  20.         return 0;
  21. }
  22. void getparameters(char url[127], char outfile[127])
  23. {
  24.         char tempurl[127];
  25.         strncpy(tempurl, url, 127);  // ** use strncpy
  26.         char tempoutfile[127];
  27.         strncpy(tempoutfile,outfile, 127); // ** use strncpy
  28.         char mplayer1[127] = "mplayer -dumpstream ";  // ** initialise
  29.         char mplayer2[127] = " -dumpfile ";
  30.         char mplayexec[127];
  31.         sprintf(mplayexec,"%s%s%s%s",mplayer1,tempurl,mplayer2,tempoutfile);
  32.         printf("\n %s\n",mplayexec);
  33.         printf("\n");
  34.         system(mplayexec);
  35. }
Jan 1 '07 #15

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

Similar topics

2
by: sivignon | last post by:
Hi, I'm writing a php script which deals with 3 ORACLE databases. This script is launch by a script shell on an linux machine like this : /../php/bin/php ./MySript.php (PHP 4.3.3) My script...
13
by: N.S. du Toit | last post by:
Just having a bit of trouble programming with C under FreeBSD 5.1 using the gcc compiler. I'm a bit new to C so my apologies if the answer to my question appear obvious :) Basically I've...
16
by: laberth | last post by:
I've got a segmentation fault on a calloc and I don'tunderstand why? Here is what I use : typedef struct noeud { int val; struct noeud *fgauche; struct noeud *fdroit; } *arbre; //for those...
6
by: damian birchler | last post by:
If I run the following I get a segmentation fault: #define NAMELEN 15 #define NPERS 10 typedef struct pers { char name; int money; } pers_t;
7
by: Alexandre | last post by:
Hello, Maybe it's a little OT, but the fact is that I don't necessarly want to know "how to correct?", but "why it happens?" I have a program who "segment fault" (ok, that's "normal"... ;-)...
27
by: Paminu | last post by:
I have a wierd problem. In my main function I print "test" as the first thing. But if I run the call to node_alloc AFTER the printf call I get a segmentation fault and test is not printed! ...
7
by: pycraze | last post by:
I would like to ask a question. How do one handle the exception due to Segmentation fault due to Python ? Our bit operations and arithmetic manipulations are written in C and to some of our...
6
by: DanielJohnson | last post by:
int main() { printf("\n Hello World"); main; return 0; } This program terminate just after one loop while the second program goes on infinitely untill segmentation fault (core dumped) on...
8
by: Bryan | last post by:
Hello all. I'm fairly new to c++. I've written several programs using std::vectors, and they've always worked just fine. Until today. The following is a snippet of my code (sorry, can't...
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$) { } ...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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.