C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 19th, 2014, 08:38 AM
Anki Anki is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2014
Posts: 1 Anki User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 m 24 sec
Reputation Power: 0
Memory & arrays - Segmentation fault (core dumped

The following is part of the code I'm working on -

Code:
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
#include "aes.h"
#include <string.h>
#define CCHMAXPATH 100
 
void encrypt(const char *fileIn, const char *fileOut,
    const unsigned char *key);
 
int main(int argc, char *argv[]) 
{
  unsigned char key[100];
  char buffer[CCHMAXPATH];
  memcpy(key,argv[2],100);
  srand(time(NULL));
 
  aes_init();
  snprintf(key,100,"home/ankita/bin/python/encrypt/%s.encrypted",argv[2]);
  encrypt(argv[1], key, argv[2]);
   
  return 0;
}


It compiles properly but when I try to run it like this
Code:
./a.out trial.doc abc ('trial.doc' - argv[1] filename and 'abc' - argv[2] key)

it gives the following error -
Code:
Segmentation fault (core dumped)


Now, I know this happens when we try to access memory that we can't. So, where am I going wrong here? I'm unable to figure out.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > Memory & arrays - Segmentation fault (core dumped


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap