somjit{} 60 Junior Poster in Training Featured Poster

I see fresh college grads all around running for a (/an almost) saturated software development field. Myself not being any exception to this either. But I'm kind of in a dilemma.

  1. I have invested around 12 months learning stuff like Java, databases and other cs stuff.
  2. but I got a job offer from a company that works in the networking domain.

many have told me that the professional environment varies with location , and I do believe enough logic to be in that statement , however I'm still making this post to ask a few questions, answer for which I would love to have from the professionals out there.

  1. Does the networking domain for freshers start from the support level? I've read a few blogs and threads which indicate that to be the norm.
  2. What opportunities for growth does this domain provide for freshers? How fast does it grow?
  3. Does the networking domain, in general pay as well as the software one? Like as in incentives, bonus, hikes and salary in general?

Some answers would help out a lot.

somjit{} 60 Junior Poster in Training Featured Poster

yes , both git and tortoisegit.

somjit{} 60 Junior Poster in Training Featured Poster

Tried the "create new repository here" option of TG (Tortoise Git) , then through the normal procedures of commit-master and then push tried to push it to the repo.
didnt work . only showed error code 1.
deleted the repo , created a fresh one , tried from scratch again , same results.
tried pulling first , then pushing , same results.
tried GitSync , same results.

after about 6 hours of frustrating permutation combination of whatever options i could think of , this is the only one thats still working

go to the required directory. > create a clone of the repo there > copy required source files into the local clone folder > push. That still works.

BUT i no longer get the TG colored icons i used to get previously.

somjit{} 60 Junior Poster in Training Featured Poster

i learnt that oneshould only keep source files in GitHub repos. so i deleted a previous repo , one with compiled class files , etc to create a new repo.
i pushed all my Source files there. all OK.
BUT , then i tried to add new source files , and MAYHEM!

Nothing is getting done , no pulls , no push , no syncs , no nothing!
whats more , the same is happening with all other Repos!

is this the end of my githubbing days ? :(

i desparately need some help here !

will provide whatever info is needed regardingthe matter. Being unsure whats causing the problem ,i didnt upload any screen shots yet.

somjit{} 60 Junior Poster in Training Featured Poster

and while you do all this , dont touch the ide.
make your memory and fingers work a little on that favourite text editor of yours.

somjit{} 60 Junior Poster in Training Featured Poster

iv have enough of compiler issues.
created a java version of the above program. gives me answers. though its for the java platform.

public class test {
    private final static int count = 500000000;
    private final static long num = 55465465465465L;
    private final static int loops = 25;
    private long runTime;
    private long result;
    private long bitArr[] = new long[loops];
    private long mulDivArr[] = new long[loops];
    private double meanVal;

    private void bitwiser() {
        for (int i = 0; i < count; i++) {
            result = num & 1;
        }
        // System.out.println("run time for bitwise op : " + runTime);
    }

    private void muldiv() {
        for (int i = 0; i < count; i++) {
            result = (num / 2) * 2;
        }
        // System.out.println("run time for muldiv op : " + runTime);
    }

    public test() {
        // run loops and gather info
        for (int i = 0; i < loops; i++) {
            runTime = System.currentTimeMillis();
            bitwiser();
            runTime = System.currentTimeMillis() - runTime;
            bitArr[i] = runTime;
            runTime = System.currentTimeMillis();
            muldiv();
            runTime = System.currentTimeMillis() - runTime;
            mulDivArr[i] = runTime;
        }
        // calculate stats
        meanVal = stats.mean(bitArr);
        System.out.println("bitwise time : " + meanVal);
        meanVal = stats.mean(mulDivArr);
        System.out.println("muldiv time : " + meanVal);

    }

    public static void main(String[] args) {
        new test();
    }
}

final class stats {
    private stats() {
        // empty
    }

    public static double mean(long[] a) {
        if (a.length == 0)
            return Double.NaN;
        long sum = sum(a);
        return (double) sum / a.length;
    }

    public static long sum(long[] a) {
        long …
somjit{} 60 Junior Poster in Training Featured Poster

does dev c/c++ support c11 ?

somjit{} 60 Junior Poster in Training Featured Poster

i modifiedmy code somewhat , but still no go

#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<stdint.h>
clock_t startm, stopm;
#define START if ( (startm = clock()) == -1) {printf("Error calling clock");exit(1);}
#define STOP if ( (stopm = clock()) == -1) {printf("Error calling clock");exit(1);}
#define PRINTTIME printf( "%ju ticks used by the processor.", (uintmax_t)(stopm-startm));
#define COUNT 18446744073709551600
#define STEP COUNT/100

int timetest(void){
    unsigned long long int i = 0, y =0 , x = 76546546545541; // x  = a random big odd number
    clock_t startTime,stopTime;
    printf("\nstarting bitwise method :\n");
    START;
    for(i = 0 ; i < COUNT ; i++){
        if(x&1) y=1;
    }
    STOP;
    printf("\n");
    PRINTTIME;

    y=0;
    printf("\nstarting mul-div method :\n");
    START;  
    for(i = 0; i < COUNT ; i++){     
        if(((x/2)*2) != x ) y=1;
    }
    STOP;
    printf("\n");
    PRINTTIME;
    printf("\n\n");
    return 0;
}

im always getting 0 ticks used by the processor. as the output.

somjit{} 60 Junior Poster in Training Featured Poster

yes , something like that ! though i doubt the starting time of 19. how did you get it ?

somjit{} 60 Junior Poster in Training Featured Poster

probably doing something fundamentally wrong , but im used to the luxury of java's System.currentTimeMillis() or System.nanoTime() unfortunately. i have a code that i posted before for a different problem (couldnt compile properly in pelles C) , but now , although its compiling well and good , my clock outputs always give zero. any help here ?

my code :

#include<stdio.h>
#include<time.h>
int main(void){
    long long int i = 0, y =0 , x = 7985463214932541; // x  = a very big odd number
    clock_t t1,t2;
    printf("\n strating bitwise method :");
    t1 = clock();
    printf("\nstarting time : %ld\n",t1);
    for(i = 0 ; i < 500000000 ; i++){
        if(x&1) y=1;
    }
    t1 = clock() - t1;
    printf("bitwise time : %15ld\n",t1);
    y=0;
    printf("\n strating mul div method : \n");
    t2 = clock();
    printf("starting time : %ld\n",t2);
    for(i = 0; i < 500000000 ; i++){
        if(((x/2)*2) != x ) y=1;
    }
    t2 = clock() - t2;    
    printf("\nmul-div time: %15ld\n\n",t2);
    return 0;
}
somjit{} 60 Junior Poster in Training Featured Poster

i see . :)

somjit{} 60 Junior Poster in Training Featured Poster

Coz i have tried this and it works swiftly.

so something that you have tried and works swiftly is lame ? ;)

lame would be something that is slow , takes a lot of memory etc etc etc.

lookup table may not necessarily be the fastest way to do things. what is fast and what is lame needs actual benchmarking. and a thorough understanding of exactly what it is that your doing.

somjit{} 60 Junior Poster in Training Featured Poster

Am aware of mathematical algorithm for binary to octal conversion, that you have to group binary digits into 3 from right and subsitute respective octal digit.

so your thinking of a lookup table. but i dont see any such code in what you have posted , also this is a shortcut in some sense . An actual algorithm is a generic process that always works , lookup tables are specific to the two bases that are being consedered.

the actual "algorithm" is this :

any base to dec :   sum: ith-num*(base^i) 
dec to any base :   succ div by required base

default way to convert from base A to base B :
convert A to dec , take that dec and convert to B.
this will work with all bases.

ps :
i post this generic method because you mentioned about "an algorithm from scratch". This might not be the most efficientway to convert between two bases, but thats a different topic.

somjit{} 60 Junior Poster in Training Featured Poster

1st of all , your goto's make it not only uncomfortable to read the code , but also , if you get into a habit of using them , i dont think thats gonna be a good idea.

2nd , give this a read.

somjit{} 60 Junior Poster in Training Featured Poster

whats gpdraw?

your post is quite laborious on the eye , maybe if you 1st describe how you are trying to solve it through your program , people here can help you out better.

somjit{} 60 Junior Poster in Training Featured Poster

divisibilty ? by what ?

if your looking for odd/even number check you can use bit-wise operations : all even numbers will have 0 in their lowest order bit , whereas odd ones will have 1. check for that , and youll get your answers.

somjit{} 60 Junior Poster in Training Featured Poster

see this
until the eof mark is set , the last entry will be repeatedly fetched . its better to use an array i feel , and in the while loop at the end , apply index < length of array condition.

somjit{} 60 Junior Poster in Training Featured Poster

my bad , my brain must had gone totally bonkers , i thought i+1 was incrementing i !!

somjit{} 60 Junior Poster in Training Featured Poster
printf("Enter Height of Student %d : ",i+1);
scanf("%d",&height);
fwrite(&height,2,1,fp);
i++;

your incrementing i twice in the same loop . i havent run your code yet , but i dont think thats how it should work.

somjit{} 60 Junior Poster in Training Featured Poster

well thats better :)

and since you figured out the main cause of the problem , i think its safe to show you a different version of your code , one that doesnt need the extra getchar() .

somjit{} 60 Junior Poster in Training Featured Poster

the suggestion i gave included a flaw in it. and i provided a hint for it also. why do you think you got an auto-return after "enter replacement character" part ?

on a different topic : whyare you giving 1 as the character to be replaced ??? where is 1 in that string you wrote ??

somjit{} 60 Junior Poster in Training Featured Poster

in java or c , if you want \ in your string , you have to give another \ before it. its the holy rule of the blackslashes . ;)

somjit{} 60 Junior Poster in Training Featured Poster

in c , passing an array is by default pass-by-reference , you dont need the char * . char s[] in both the declaration and definition would do well enough i think.

did you try what i said above there ?

edit : whats with the getch() ? if your running from the default windows cmd, you wont need getch() . if your using a modern IDE , they provide the getch() facilty built in. if your using something old like turbo c , i suggest its time you make a shift. :)

somjit{} 60 Junior Poster in Training Featured Poster

ok.
try replacing the 1st scanf() , the one that reads a line , with fgets() , then replace the two scanf()'s that come after that with getchar()'s.
then youll see that it also wont work , but it should give you an idea regarding scanf()s and getchars() and stdin.
HINT : its about stuff that gets left behind in the input stream.

also , a question : in the function declaration , you mention char * but in the definition ( that is waht they are called if i remember correctly ) below the main , you write char s[] . why so ?

somjit{} 60 Junior Poster in Training Featured Poster

welcome to daniweb :)

apart from scanner , you can also try out a BufferedReader .
i dont really see console being used for this kind of stuff. any particular reason you're using it ?

also , whatever you choose to use , its a good practice to close the io stream after your done with it. traditionally its done inside a finally() block , but with java 7 , a fancy try with resources block can be used.
you can check it out here .

somjit{} 60 Junior Poster in Training Featured Poster

why do i have to put 4 '\' in the Pattern.compile??

because you have 2 \ in your string , and so , one extra \ for each.

somjit{} 60 Junior Poster in Training Featured Poster

yo !

somjit{} 60 Junior Poster in Training Featured Poster

ps : Click Here

:D

somjit{} 60 Junior Poster in Training Featured Poster

writing regex pattern for all of them would be impossible

complicated ? yes , impossible : no.
example : <[^>]*> can be used in conjuction with a replace by "" to remove non nested html tags.

.i need to convert the escaped hex values into their corresponding ascii.

i hope you dont plan to check them one by one after that ? thats gonna be quite slow.

somjit{} 60 Junior Poster in Training Featured Poster

try this regex pattern
H\w+,\s+W\w+ this is tailor made to get "Hello, World".

it starts with H , looks for all word characters from H (the \w+ part), this stops at the first comma , then include one or many whitespace (via \s+ ) , then do what you did in case of H but with W.

somjit{} 60 Junior Poster in Training Featured Poster

i think i have an idea of whats happening , but when you say awkward output , posting the awkwardness here would help tame it :)

note : scanf() to read a character is a very bad idea.
read more from here

somjit{} 60 Junior Poster in Training Featured Poster

you can use methods of the java String class to extract hello world out of the string above. the methods are all listed there. i dont know much about web stuff , but feed the above into a string , and apply the methods you think will be best from the list.

your best bet will be regexes imo , if you're familiar with them. if not , and you want to try them out , this may help you.

somjit{} 60 Junior Poster in Training Featured Poster

thanks a lot for your help :)
marking thread solved :)

somjit{} 60 Junior Poster in Training Featured Poster

im yet to work with ant or maven (quite new to java still) and didnt have much idea about good posting habits on github. ill look into these.

you should have searched for the .class files.

umm , im not sure what that meant , the class files were inside the bin , and the bin had itself vanished.

regarding github practices , iv seen some people post onlythe source files , is that good ?
so far , i work alone , and i use eclipse when things get complicated , so i thought of uploading the entire project "as-is" so that if i have to explain sommething to some friends , i can just directly pull stuff from the repo into a different machine and not have to worry about their settings. a double bonus i felt was that it could act as a backup.
not a good practice it now seems to be.

somjit{} 60 Junior Poster in Training Featured Poster

your trying to read a string into card_name , but unlike java or some oop languages , C doesnt by default support strings , a string is a char array much like the one you have here , but , you have to populate the array one char at a time.
like

char c , s[100] ;
int i = 0;
while((c = getchar())!= '\n'){
    s[i++] = c;
}
s[i] = '\0';

this is to give you a basic idea how things work.
once you understand this , and get the hang of stuff , id suggest you take a look at fgets-sscanf combo for taking in string inputs.

somjit{} 60 Junior Poster in Training Featured Poster

also , it is a better practice to write like
int main(void){} when your not passing any arguments.

when you write even something like main(){..} it works because in C , when ever the compiler sees a name that has not yet been seen , in this case main , followed by an open parenthesis , it assumes it to be a function of a return type int . which is what it would be when you use int main().
and regarding the void , when not passing any arguments to main , its a good practice ( as per K&R ) to pass it a void. because not passing anything makes the compiler turn off all types of parameter checking for the function.

somjit{} 60 Junior Poster in Training Featured Poster

iv read very good things about Robert Sedgewick's algorithms in C books . i personally have his java books , and i love them.
if you are interested in algorithms , and wont mind a bit of java , theres a MOOC on algorithms starting at coursera from tommorow , and the guy teaching it will be Robert Sedgewick himself. give it a try.

ps : i hope the mods wont take this as a adv/spam :P

somjit{} 60 Junior Poster in Training Featured Poster

update : deleting the project folder , and making a fresh clone of the github repo solved some of the problems , mainly :

  1. compiling code from eclipse auto popularizes the bin folder with class files.
  2. hitting run from eclipse no longer says : cannot find main class (as a consequence of above point)

but i would still love to know if someone has any opinion about the initial problem. what may have caused it , and has anyone else faced something like this.

thanks for your time.
regards.

somjit{} 60 Junior Poster in Training Featured Poster

whats even more is that if i create any new file in the "src" folder of the project , it doesnt create any new bin folder to place the class file. i dont know where the class files are of the compiled source code . only when i manually javac -d ..\bin test.java-d a test code from the cmd, a new bin folder got created.

anyone have any idea why this is happening ?

i had the project folder synced to a repository on github , and the repo has all the bin and the class files , but when i try to pull from the repo , it says successfully pulled , but no class files are getting downloaded into my hard disk.

somjit{} 60 Junior Poster in Training Featured Poster

this and this should give you some ideas.

basically , expanding what stultuske already said :

have a class for comparing your values , it will implement comparator (or comparable) . Hence by rules if interface implementation , you have to override the interface's method : compare(T o1, T o2) in case you choose to use comparator.
then , test for the 1st parameter with which you want to order,
if that results in an equality , test for the 2nd parameter.. and so on.

give it a try.

somjit{} 60 Junior Poster in Training Featured Poster

what malloc does is basically frees you from having to think too hard about what the size of your array should be during its definition , as it lets you modify memory space on the fly.this and this should get you started.

somjit{} 60 Junior Poster in Training Featured Poster

to add to what James had already mentioned , you have defined your Team class' constructor to take an argument of type game , but in game.addTeam(new Team(teamName)); your passing a string to the constructor.
Also , your trying to use ArrayList , but you have to import them first in order to do so.

somjit{} 60 Junior Poster in Training Featured Poster

going by deceptikon's advice regarding using a console application , and adak's advice regarding compiling/executing from within the ide , the original problems are no longer coming up.
marking this thread solved.

somjit{} 60 Junior Poster in Training Featured Poster

naive , idiotic posts like these not only make you look stupid , but also invites bias from the global audience towards people from your part of the world.

im not far from where you are , and if you want a job after what your doing now , i suggest you spend time on something you're more familiar with already. something which you can work on and then post on forums when you face some troubles implementing your ideas.

somjit{} 60 Junior Poster in Training Featured Poster

and remember to use the compile button in the IDE, not the command line.

it runs as it should with the 'execute' button in the ide , but cmd still no go.

ill sign up there :)

bdw , im sure people (including me) would like to know that workaround you mentioned. maybe post a new thread regarding that ?

somjit{} 60 Junior Poster in Training Featured Poster

if i execute from the ide , its working , but if i try to do it from cmd , its not. i really have no idea what to do here. mine is a 64bit system , do you think that has to do anything with it ?

somjit{} 60 Junior Poster in Training Featured Poster

thanks :) all those options at start of a project got me ...
but , regarding the 2nd issue ,when i compile like
gcc -o test test.c from command line , i am compling with the old gcc compiler right ? so if the code has long long int in there , which isnt supported before c99 , shouldnt i get a compile time error ?

also , currently , i compile my codes in these two steps :
1. gcc -o test test.c
2. test
from windows defaylt cmd,

i tried to compile from pelles 's command line using the cc /Ze test.c command i found in here, but it gave me a lot of errors . i couldnt copy paste them here as it lacked enough readabilty, so im uploading a screenshot of the errors.

can you help me out with this one too ?

somjit{} 60 Junior Poster in Training Featured Poster

update : something weird happend just.

  1. after installing pelles c, even when im using gcc commands on command line , (so i think im using the old compiler) the newer long long int versions are being supported , ie not getting any compile time errors for it.
  2. clock() is giving time like 1 , 2 etc ... which i dont think how it should give.
somjit{} 60 Junior Poster in Training Featured Poster

@rubberman :

Building LearningC.exe.
POLINK: error: Unresolved external symbol 'WinMain'.
POLINK: fatal error: 1 unresolved external(s).
*** Error code: 1 ***
Done.

somjit{} 60 Junior Poster in Training Featured Poster

while trying to compare times between two different ways of determing whether a number is odd/even without using modulo, i thought of using long long ints which my codeblocks compiler aint supports .
and so i installed pelles c.( supports c99/c11 which inturn supports long long stuff.. )
and im down with linker errors. problems :

  1. i dont understand much what they are ,
  2. google led me to some pelles c forum threads where the discussion went above my head ( note : but it was related to the problem i had )
  3. i tried looking into pelles c help (which is raather nice bdw) but didnt find (didnt know where to look maybe) much.

can someone help me getting these things sorted ?
this is my code :

#include<stdio.h>
#include<time.h>
int main(){
    long long int i = 0, y =0 , x = 7985463214932541; // x  = a very big odd number
    clock_t t1,t2;
    printf("starting..\n");
    t1 = clock();
    for(i = 0 ; i < 500000000 ; i++){
        if(x&1) y=1;
    }
    t1 = clock() - t1;
    y=0;
    t2 = clock();
    for(i = 0; i < 500000000 ; i++){
        if(((x/2)*2) != x ) y=1;
    }
    t2 = clock() - t2;
    printf("bitwise time : %15ld\n",t1);
    printf("\nmul-div time: %15ld",t2);
    return 0;
}

also , while creating a new project in pelles c, i get tons of options as tp the project type , im just lerning c as of now , basic stuff.. so which one should …